using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace NodeCanvas.Tasks.Actions { [Category("Movement/Direct")] [Description("Move & turn the agent based on input values provided ranging from -1 to 1, per second (using delta time)")] public class InputMove : ActionTask { [BlackboardOnly] public BBParameter strafe; [BlackboardOnly] public BBParameter turn; [BlackboardOnly] public BBParameter forward; [BlackboardOnly] public BBParameter up; public BBParameter moveSpeed = 1; public BBParameter rotationSpeed = 1; public bool repeat; protected override void OnUpdate() { var targetRotation = agent.rotation * Quaternion.Euler(Vector3.up * turn.value * 10); agent.rotation = Quaternion.Slerp(agent.rotation, targetRotation, rotationSpeed.value * Time.deltaTime); var forwardMovement = agent.forward * forward.value * moveSpeed.value * Time.deltaTime; var strafeMovement = agent.right * strafe.value * moveSpeed.value * Time.deltaTime; var upMovement = agent.up * up.value * moveSpeed.value * Time.deltaTime; agent.position += strafeMovement + forwardMovement + upMovement; if ( !repeat ) { EndAction(); } } } }