change: changing how swing direction is handled
This commit is contained in:
@@ -4,6 +4,7 @@ using log4net.Appender;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Services;
|
||||
using Reset.Core.Tools;
|
||||
using Reset.Units;
|
||||
using Sirenix.Serialization;
|
||||
using Unity.Cinemachine;
|
||||
@@ -61,8 +62,14 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
//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(){
|
||||
DebugOverlayDrawer.AddOnOverlay("Grapple", "Composite Swing Direction", Vector3.zero);
|
||||
DebugOverlayDrawer.AddOnOverlay("Grapple", "Target Swing Direction", Vector3.zero);
|
||||
DebugOverlayDrawer.AddOnOverlay("Grapple", "Smoothed Input", Vector3.zero);
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
@@ -73,17 +80,13 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
MonoManager.current.onLateUpdate += DrawGrappleGizmo;
|
||||
// Set the initial direction
|
||||
directionOnStart = agent.transform.position.DirectionTo(grapplePoint.value);
|
||||
|
||||
|
||||
|
||||
// Get the current move direction
|
||||
velocityOnStart = agent.outputMoveDirection;
|
||||
|
||||
|
||||
// Lerp the initial direction more towards the point of the grapple and less towards current momentum if not moving fast
|
||||
finalDirection = Vector3.Lerp(velocityOnStart, directionOnStart, velocityOnStart.magnitude / 10f);
|
||||
|
||||
|
||||
startTime = Time.time;
|
||||
currentSpeed = pullSpeedCurve.value[0].value * pullSpeedRange.value.y;
|
||||
|
||||
@@ -100,7 +103,8 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
Vector3 input = new(rawInput.x, rawInput.y, 0f);
|
||||
|
||||
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 2);
|
||||
|
||||
DebugOverlayDrawer.ChangeValue("Grapple", "Smoothed Input", smoothedInput.ToString());
|
||||
|
||||
// Change input handling based on position
|
||||
if (directionToPoint.y < 0) {
|
||||
|
||||
@@ -116,14 +120,21 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
Vector3 upwardsSwingAngle = Quaternion.AngleAxis(-90f, Vector3.right) * directionToPoint;
|
||||
// Vector3 downwardsSwingAngle = Quaternion.AngleAxis(90f, Vector3.right) * directionToPoint; // why not just use upwards but negative based on input on Y
|
||||
|
||||
// Create the composite swing direction
|
||||
// Create the composite swing direction and the target swing direction
|
||||
// The composite is the output while the target is the one used in calculating
|
||||
Vector3 compositeSwingDirection;
|
||||
Vector3 targetSwingDirection;
|
||||
|
||||
// if (directionToPoint.y > 0) {
|
||||
Vector3 swingAngleAbovePoint = Vector3.Slerp(upwardsSwingAngle, -upwardsSwingAngle, Mathf.Abs((smoothedInput.y + 1f) / 2));
|
||||
DebugOverlayDrawer.ChangeValue("Grapple", "Target Swing Direction", Mathf.Abs((smoothedInput.y + 1f) / 2).ToString());
|
||||
Vector3 swingAngleAbovePoint = -upwardsSwingAngle;
|
||||
|
||||
if (Mathf.Abs(smoothedInput.y) > .01f){
|
||||
swingAngleAbovePoint = Vector3.Slerp(-upwardsSwingAngle, upwardsSwingAngle, Mathf.Abs((smoothedInput.y + 1f) / 2));
|
||||
}
|
||||
Vector3 axisFromInput = Vector3.zero;
|
||||
|
||||
if (smoothedInput.x >= 0) {
|
||||
if (smoothedInput.x > 0) {
|
||||
axisFromInput = Vector3.Slerp(swingAngleAbovePoint, sidewaysSwingAngle, smoothedInput.x);
|
||||
}
|
||||
|
||||
@@ -139,7 +150,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
// Some math for getting the Y
|
||||
yChangeMultipler = Mathf.Lerp(yChangeMultipler, 0f, elapsedTime * .5f); // Starts at 1 so that the player has more ability to change height on start of swing, then smooths to zero
|
||||
|
||||
|
||||
DebugOverlayDrawer.ChangeValue("Grapple", "Composite Swing Direction", compositeSwingDirection.ToString());
|
||||
Debug.Log(Vector3.Dot(directionToPoint, Vector3.down));
|
||||
|
||||
// Speed
|
||||
@@ -170,7 +181,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
gizmoVertValue = finalDirection.y;
|
||||
gizmosSmoothedInput = smoothedInput;
|
||||
gizmoPointDirection = directionToPoint;
|
||||
gizmoSwingDirection = compositeSwingDirection;
|
||||
gizmoSwingDirection = swingAngleAbovePoint;
|
||||
gizmoFinalDirection = finalDirection;
|
||||
|
||||
//Test
|
||||
|
||||
Reference in New Issue
Block a user