From 577659458e49b53415bced219db6009f9b2d8504 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 15 Jul 2025 18:15:00 -0400 Subject: [PATCH 1/2] fix: corrected math for air directional jumping --- Assets/Scripts/Core/Graph Tasks/AddJump.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Core/Graph Tasks/AddJump.cs b/Assets/Scripts/Core/Graph Tasks/AddJump.cs index 9b6ea07..7c8cc13 100644 --- a/Assets/Scripts/Core/Graph Tasks/AddJump.cs +++ b/Assets/Scripts/Core/Graph Tasks/AddJump.cs @@ -53,7 +53,7 @@ namespace NodeCanvas.Tasks.Actions { // Save current velocity and get current input direction Vector3 currentVelocityVector3 = new Vector3(agent.velocity.x, 0f, agent.velocity.z); Vector2 currentInput = agent.GetComponent().rawMoveInput; - Vector3 currentInputVector3 = Camera.main.transform.rotation.Flatten(0, null, 0) * new Vector3(currentInput.x, 0f, currentInput.y); + Vector3 currentInputVector3 = new Vector3(currentInput.x, 0f, currentInput.y); // Ignore rotation for the current velocity Vector3 currentVelocityWorld = agent.transform.InverseTransformDirection(currentVelocityVector3.normalized); @@ -82,7 +82,7 @@ namespace NodeCanvas.Tasks.Actions { remappedAirDirectionDot = Mathf.Clamp(remappedAirDirectionDot, 0f, 1f); // Lerp between the current direction and the inputted direction based on the previous dot product - Vector3 outputDirection = Vector3.Lerp(currentVelocityVector3.normalized, currentInputVector3.normalized, remappedAirDirectionDot); + Vector3 outputDirection = Vector3.Lerp(currentInputVector3.normalized, currentVelocityVector3.normalized, remappedAirDirectionDot); // If there is a direction force, lean into that based on it's strength outputDirection = Vector3.Lerp(outputDirection, directionalForce.value.normalized, directionalForceStrength.value).normalized; @@ -90,7 +90,10 @@ namespace NodeCanvas.Tasks.Actions { // Extra math to degrade current air move direction by velocity inheritence, before applying new air direction airMoveDirection.value *= currentVelocityInheritence.value; - // Set air move direciton + // Account for the camera's rotation before setting it as the air move direction + outputDirection = Camera.main.transform.rotation.Flatten(0, null, 0) * outputDirection; + + // Set air move direction airMoveDirection.value += outputDirection * outputVelocity; } From 8e986bc754f9ee1dd256f667aa6bcd775592f868 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 15 Jul 2025 18:15:30 -0400 Subject: [PATCH 2/2] maint: cleaned up some of the notes and whitespace --- Assets/Scripts/Core/Graph Tasks/AddJump.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Core/Graph Tasks/AddJump.cs b/Assets/Scripts/Core/Graph Tasks/AddJump.cs index 7c8cc13..fe92eb3 100644 --- a/Assets/Scripts/Core/Graph Tasks/AddJump.cs +++ b/Assets/Scripts/Core/Graph Tasks/AddJump.cs @@ -78,13 +78,13 @@ namespace NodeCanvas.Tasks.Actions { // Remap the dot to set -1 (opposing direction) to -.5f, and 1 (same direciton) to 1.2f // This is done to allow some sideways jumping direction change, but none backwards, and all forwards - float remappedAirDirectionDot = Mathf.Lerp(.3f, 1.2f, airMoveDirectionDot); + float remappedAirDirectionDot = Mathf.Lerp(.1f, 1.2f, airMoveDirectionDot); remappedAirDirectionDot = Mathf.Clamp(remappedAirDirectionDot, 0f, 1f); - + // Lerp between the current direction and the inputted direction based on the previous dot product Vector3 outputDirection = Vector3.Lerp(currentInputVector3.normalized, currentVelocityVector3.normalized, remappedAirDirectionDot); - // If there is a direction force, lean into that based on it's strength + // If there is a directional force (such as the Wall Climb jump going straight upward) supplied in the task, lean into that based on it's strength outputDirection = Vector3.Lerp(outputDirection, directionalForce.value.normalized, directionalForceStrength.value).normalized; // Extra math to degrade current air move direction by velocity inheritence, before applying new air direction @@ -96,7 +96,6 @@ namespace NodeCanvas.Tasks.Actions { // Set air move direction airMoveDirection.value += outputDirection * outputVelocity; } - EndAction(true); }