added: fully functional grapple launch and 90% functional grapple pull
This commit is contained in:
71
Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs
Normal file
71
Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Player.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<CharacterController>{
|
||||
public BBParameter<Vector3> airDirection;
|
||||
public BBParameter<float> jumpPower;
|
||||
|
||||
public BBParameter<Vector3> targetLocation;
|
||||
public BBParameter<Vector3> offset;
|
||||
|
||||
public BBParameter<Vector3> relativeRotation;
|
||||
|
||||
public BBParameter<PlayerFacingDirection> launchRelativeTo;
|
||||
|
||||
|
||||
public BBParameter<bool> useRelativeForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> minimumForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> maximumForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> forceRelativeToDistance;
|
||||
public BBParameter<float> 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() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs.meta
Normal file
2
Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f32fe451feb2ca4e8159d4aa8919cd2
|
||||
Reference in New Issue
Block a user