diff --git a/Assets/Scripts/Core/Graph Tasks/AddJump.cs b/Assets/Scripts/Core/Graph Tasks/AddJump.cs index fe92eb3..bac5bd7 100644 --- a/Assets/Scripts/Core/Graph Tasks/AddJump.cs +++ b/Assets/Scripts/Core/Graph Tasks/AddJump.cs @@ -10,19 +10,23 @@ using Reset.Player.Movement; namespace NodeCanvas.Tasks.Actions { [Category("Reset/Movement")] public class AddJump : ActionTask { - public BBParameter jumpStrength; public BBParameter airMoveDirection; - - public BBParameter playerFacingDirection; + public BBParameter jumpPower; - [Range(0f, 1f)] + [Space(5)] + public BBParameter jumpStrength; + + [SliderField(0, 1)] public BBParameter standStillJumpStrength; - public BBParameter jumpPower; + + [Tooltip("Determines how much current movement vectors into jump direction")] + [SliderField(0, 1)] public BBParameter currentVelocityInheritence; public BBParameter directionalForce; + [SliderField(0, 1)] public BBParameter directionalForceStrength; protected override string info { @@ -72,9 +76,12 @@ namespace NodeCanvas.Tasks.Actions { // Check threshold of current XZ velocity- if it's too close to zero, use the jumpStrength for jumping velocity. If it's not, use the current velocity float velocityThreshold = 4f; float magnitudeZeroDifference = Mathf.Clamp(currentVelocityVector3.magnitude - velocityThreshold, 0f, Mathf.Infinity) / velocityThreshold; // Divided by maximum to return a 0-1 value. Clamping not required. - float outputVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f)); + float outputHoritontalVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f)); + + outputHoritontalVelocity = Mathf.Min(outputHoritontalVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference)); - outputVelocity = Mathf.Min(outputVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference)); + // Do the same for directional jump strength + outputHoritontalVelocity = Mathf.Lerp(outputHoritontalVelocity, jumpStrength.value, directionalForceStrength.value); // 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 @@ -94,7 +101,7 @@ namespace NodeCanvas.Tasks.Actions { outputDirection = Camera.main.transform.rotation.Flatten(0, null, 0) * outputDirection; // Set air move direction - airMoveDirection.value += outputDirection * outputVelocity; + airMoveDirection.value += outputDirection * outputHoritontalVelocity; } EndAction(true); }