change: separated all functions of movement into separate tasks
This commit is contained in:
48
Assets/Scripts/Core/Graph Tasks/FinalizeMovement.cs
Normal file
48
Assets/Scripts/Core/Graph Tasks/FinalizeMovement.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Movement {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Finalize the move direction to the agent's CharacterController")]
|
||||
public class FinalizeMovement : ActionTask<CharacterController>{
|
||||
public BBParameter<Vector3> moveDirection;
|
||||
public BBParameter<float> currentSpeed;
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
if (currentSpeed == null || !currentSpeed.useBlackboard) {
|
||||
Debug.LogError("This <b>Finalize Movement</b> does not have it's current value attached to a Blackboard variable. Nothing will happen.", agent.gameObject);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate(){
|
||||
Vector3 usableVector3 = new Vector3(moveDirection.value.x * currentSpeed.value, moveDirection.value.y, moveDirection.value.z * currentSpeed.value);
|
||||
agent.Move(Camera.main.transform.rotation * usableVector3 * Time.deltaTime);
|
||||
|
||||
Debug.Log("Finalize Done");
|
||||
// EndAction(true);
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user