Character Controller Move#
Physics / Collider / Character Controller / Character Controller Move
Description#
Supplies the movement of a Game Object with an attached Character Controller component
Note
The Character Controller Move motion moves the GameObject in the given direction
Note
The given direction requires absolute movement delta values
Note
A collision constrains the Move from taking place
Note
Character Controller Move does not use gravity
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 Move")]
[Image(typeof(IconCapsuleSolid), ColorTheme.Type.Lime, typeof(BadgeArrowRight))]
[Description("Supplies the movement of a Game Object with an attached Character Controller component")]
[Category("Physics/Collider/Character Controller/Move")]
[Parameter("Character Controller", "The Character Controller component on a Game Object")]
[Note("The Character Controller Move motion moves the GameObject in the given direction")]
[Note("The given direction requires absolute movement delta values")]
[Note("A collision constrains the Move from taking place")]
[Note("Character Controller Move does not use gravity")]
[Note("It is recommended that you make only one call per frame")]
[Serializable]
public class InstructionCoreCharacterControllerMove : Instruction
{
[SerializeField] private GetGameObject m_CharacterController =
new GetGameObject(
new TypeGameObjectComponentCharacterController()
);
[SerializeField] private GetVector3 m_Motion = new GetVector3();
protected override string GetTitle(GameObject source) => $"{this.m_CharacterController} Move {this.m_Motion}";
protected override Awaitable Run(Args args)
{
CharacterController controller = this.m_CharacterController.Get<CharacterController>(args);
if (controller == null) return Done;
Vector3 motion = this.m_Motion.Get(args);
controller.Move(motion);
return Done;
}
}
}