using System; using NodeCanvas.Framework; using ParadoxNotion.Design; using Reset.Movement; using UnityEngine; namespace NodeCanvas.Tasks.Actions { [Category("Reset/Movement")] [Description("Launch the agent towards a specific point with respect to distance.")] public class StartLaunchJump : ActionTask{ public BBParameter airDirection; public BBParameter jumpPower; public BBParameter targetLocation; public BBParameter offset; public BBParameter relativeRotation; public BBParameter launchRelativeTo; public BBParameter useRelativeForce; [ShowIf("useRelativeForce", 1)] public BBParameter minimumForce; [ShowIf("useRelativeForce", 1)] public BBParameter maximumForce; [ShowIf("useRelativeForce", 1)] public BBParameter forceRelativeToDistance; public BBParameter force; //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(){ Vector3 launchDir = agent.transform.position.DirectionTo(targetLocation.value).normalized; launchDir = Quaternion.Euler(relativeRotation.value) * launchDir; Debug.Log(launchDir); float distanceToTarget = Vector3.Distance(agent.transform.position, targetLocation.value); float outputForce = (useRelativeForce.value ? distanceToTarget * forceRelativeToDistance.value : force.value); outputForce = Mathf.Clamp(outputForce, minimumForce.value, maximumForce.value); jumpPower.value = outputForce; airDirection.value = (launchDir * outputForce); EndAction(true); } //Called once per frame while the action is active. protected override void OnUpdate() { } //Called when the task is disabled. protected override void OnStop() { } //Called when the task is paused. protected override void OnPause() { } } }