fixed: changed how rotation is handled in transition from grounded to air to account for becoming grounded without jumping
This commit is contained in:
56
Assets/Scripts/Core/Graph Tasks/SetAirMovement.cs
Normal file
56
Assets/Scripts/Core/Graph Tasks/SetAirMovement.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions {
|
||||
|
||||
[Category("Reset")]
|
||||
[Description("Hard set the air direction to a certain direction")]
|
||||
public class SetAirMovement : ActionTask<Transform>{
|
||||
public BBParameter<Vector3> airMoveDirection;
|
||||
|
||||
public BBParameter<Vector3> inputVector3;
|
||||
public Space fromSpace;
|
||||
public Space toSpace;
|
||||
|
||||
//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() {
|
||||
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() {
|
||||
if (fromSpace == toSpace) {
|
||||
airMoveDirection.value = inputVector3.value;
|
||||
}
|
||||
|
||||
// NOTE: I swear to God these absolutely do not work and nobody could convince me otherwise
|
||||
if (fromSpace == Space.World){
|
||||
airMoveDirection.value = Camera.main.transform.rotation.Flatten(0, null, 0) * inputVector3.value;
|
||||
} else {
|
||||
airMoveDirection.value = Camera.main.transform.rotation.Flatten(0, null, 0) * agent.InverseTransformVector(inputVector3.value);
|
||||
}
|
||||
|
||||
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