Character Controller Simple Move#
Physics / Collider / Character Controller / Character Controller Simple Move
Description#
Moves the character with speed
Note
Velocity along the y-axis is ignored
Note
Speed is in units per second
Note
Gravity is automatically applied
Note
It is recommended that you make only one call per frame
Parameters#
| Name | Description |
|---|---|
| Character Controller | The Character Controller component on a Game Object |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Character Controller Simple Move")]
[Image(typeof(IconCapsuleSolid), ColorTheme.Type.Lime, typeof(BadgeArrowRight))]
[Description("Moves the character with speed")]
[Category("Physics/Collider/Character Controller/Simple Move")]
[Parameter("Character Controller", "The Character Controller component on a Game Object")]
[Note("Velocity along the y-axis is ignored")]
[Note("Speed is in units per second")]
[Note("Gravity is automatically applied")]
[Note("It is recommended that you make only one call per frame")]
[Serializable]
public class InstructionCoreCharacterControllerSimpleMove : Instruction
{
[SerializeField] private GetGameObject m_CharacterController =
new GetGameObject(
new TypeGameObjectComponentCharacterController()
);
[SerializeField] private GetVector3 m_Speed = new GetVector3();
protected override string GetTitle(GameObject source) => $"{this.m_CharacterController} Simple Move {this.m_Speed}";
protected override Awaitable Run(Args args)
{
CharacterController controller = this.m_CharacterController.Get<CharacterController>(args);
if (controller == null) return Done;
Vector3 speed = this.m_Speed.Get(args);
controller.SimpleMove(speed);
return Done;
}
}
}