diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs b/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs deleted file mode 100644 index 69f15df..0000000 --- a/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using NodeCanvas.Framework; -using ParadoxNotion.Design; -using Reset.Units; -using Sirenix.OdinInspector.Editor; -using UnityEngine; - -namespace Reset.Core { - [Category("Reset")] - [Description("Commits movement unit changes to the handler.")] - public class ChangeMovementSettings : ActionTask { - - - [ParadoxNotion.Design.Header("Speed")] - public FloatValueGroup moveSpeed = new (newLabel: "Move Speed"); - public FloatValueGroup moveSpeedSoothing = new (newLabel: "Move Speed Smoothing"); - - [ParadoxNotion.Design.Header("Direction")] - - public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay"); - public FloatValueGroup accelerationSmoothing = new (newLabel: "Acceleration Smoothing"); - public FloatValueGroup deaccelerationSmoothing = new (newLabel: "Deacceleration Smoothing"); - // public CurveValueGroup deaccelerationCurve = new (newLabel: "Deacceleration Curve"); // Currently unused, may return - - // Jumping - [ParadoxNotion.Design.Header("Jumping")] - public FloatValueGroup jumpPower = new (newLabel: "Jump Power"); - public FloatValueGroup jumpPowerDecay = new (newLabel: "Jump Decay Speed"); - - // Gravity - [ParadoxNotion.Design.Header("Gravity")] - public FloatValueGroup gravityPower = new (newLabel: "Gravity Power"); - public FloatValueGroup gravityMax = new (newLabel: "Gravity Max"); - public FloatValueGroup gravityAcceleration = new (newLabel: "Gravity Acceleration Speed"); - public FloatValueGroup gravityScale = new (newLabel: "Gravity Scale"); - public FloatValueGroup settingsChangeSmoothing = new(newLabel: "Settings Change Smoothing"); - - // Rotation - [ParadoxNotion.Design.Header("Rotation")] - public EnumValueGroup rotateFacing = new EnumValueGroup("Facing Direction", PlayerFacingDirection.TowardsTarget); - public FloatValueGroup rotationSpeed = new (newLabel: "Rotation Speed"); - public FloatValueGroup rotationSmoothing = new (newLabel: "Rotation Smoothing"); - public FloatValueGroup rotationInputBlending = new("Rotation Input Blending"); - [Space(5)] - public BBParameter feedNewRotation; - public BBParameter feedRelativeTo; - public Space rotationRelativeSpace; - - private Vector3 feedDir; - - 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() { - // // Direction - // FloatValueGroup.UpdateValue(airDirectionDecay, ref agent.data.airDirectionDecay, ref agent.defaultData.airDirectionDecay); - // FloatValueGroup.ChangeSmoothingEasing(airDirectionDecay, - // ref agent.smoothing.airDirectionDecay, - // ref agent.easing.airDirectionDecay, - // ref agent.defaultSmoothing.airDirectionDecay, - // ref agent.defaultEasing.airDirectionDecay - // ); - // - // UpdateFloatValue(accelerationSmoothing, ref agent.data.accelerationSmoothing, ref agent.defaultData.accelerationSmoothing); - // UpdateFloatValue(deaccelerationSmoothing, ref agent.data.deaccelerationSmoothing, ref agent.defaultData.deaccelerationSmoothing); - // // UpdateCurveProperty(deaccelerationCurve, ref agent.data.deaccelerationCurve, ref agent.defaultData.deaccelerationCurve); // Currently unused, may return - // - // - // - // // Move Speed - // UpdateFloatValue(moveSpeed, ref agent.data.moveSpeed, ref agent.defaultData.moveSpeed); - // UpdateFloatValue(moveSpeedSoothing, ref agent.data.moveSpeedSoothing, ref agent.defaultData.moveSpeedSoothing); - // - // // Jump - // UpdateFloatValue(jumpPower, ref agent.data.jumpPower, ref agent.defaultData.jumpPower); - // UpdateFloatValue(jumpPowerDecay, ref agent.data.jumpPowerDecay, ref agent.defaultData.jumpPowerDecay); - // - // // Gravity - // UpdateFloatValue(gravityPower, ref agent.data.gravityPower, ref agent.defaultData.gravityPower); - // UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax); - // UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration); - // UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale); - // UpdateFloatValue(settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing, ref agent.defaultData.settingsChangeSmoothing); - // - // // Rotation - // UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing); - // UpdateFloatValue(rotationSpeed, ref agent.data.rotationSpeed, ref agent.defaultData.rotationSpeed); - // UpdateFloatValue(rotationSmoothing, ref agent.data.rotationSmoothing, ref agent.defaultData.rotationSmoothing); - // UpdateFloatValue(rotationInputBlending, ref agent.data.rotationInputBlending, ref agent.defaultData.rotationInputBlending); - - // Rotation from value - if (feedNewRotation.value != Vector3.zero) { - if (rotationRelativeSpace == Space.World) { - Debug.Log(Quaternion.LookRotation(feedRelativeTo.value)); - agent.SetSpecifiedRotation(Quaternion.Euler(feedNewRotation.value) * Quaternion.LookRotation(feedRelativeTo.value)); - } else { - agent.SetSpecifiedRotation(agent.transform.rotation * Quaternion.Euler(feedNewRotation.value) * Quaternion.LookRotation(feedRelativeTo.value)); - } - } - - 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() { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs.meta b/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs.meta deleted file mode 100644 index 9508a6d..0000000 --- a/Assets/Scripts/Core/Graph Tasks/ChangeMovementSettings.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 5132a76af4f722e49bc7fbbc75edcaf1 \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeDirectionSettings.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeDirectionSettings.cs index 155389a..688f612 100644 --- a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeDirectionSettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeDirectionSettings.cs @@ -3,7 +3,6 @@ using ParadoxNotion.Design; using Reset.Core; using UnityEngine; - namespace Reset.Units { [Category("Reset/Movement")] diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeGravitySettings.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeGravitySettings.cs index 05a5ea2..9ae4105 100644 --- a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeGravitySettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeGravitySettings.cs @@ -1,10 +1,8 @@ -using System; using NodeCanvas.Framework; using ParadoxNotion.Design; using Reset.Core; using UnityEngine; - namespace Reset.Units { [Category("Reset/Movement")] diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeMoveSpeedSettings.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeMoveSpeedSettings.cs index 5ae3e2f..f77d248 100644 --- a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeMoveSpeedSettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeMoveSpeedSettings.cs @@ -3,7 +3,6 @@ using ParadoxNotion.Design; using Reset.Core; using UnityEngine; - namespace Reset.Units { [Category("Reset/Movement")] diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeRotationSettings.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeRotationSettings.cs index 361bc1c..c729778 100644 --- a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeRotationSettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/ChangeRotationSettings.cs @@ -1,5 +1,3 @@ -using System; -using Codice.Client.BaseCommands; using NodeCanvas.Framework; using ParadoxNotion.Design; using Reset.Core; diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs new file mode 100644 index 0000000..90eb2cc --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs @@ -0,0 +1,57 @@ +using NodeCanvas.Framework; +using ParadoxNotion.Design; +using UnityEngine; + + +namespace Reset.Units { + [Category("Reset/Movement")] + [Description("Set a new direction value for this agent, either additively, absolutely, or relatively.")] + public class SetNewDirection : ActionTask { + public BBParameter newDirection; + [Tooltip("Setting absolute to true will cause the resolved movement direction to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement direction. Both options use relativty for linear interpolation.")] + public BBParameter absolute; + [Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")] + [SliderField(0, 1)] + public BBParameter relativity; + + [Tooltip("Setting raw direciton will affect things that read the raw direction like rotation")] + public BBParameter setRawAsWell; + + [Tooltip("This is set as a Vector3 but will be translated into a Vector2 on execute")] + public BBParameter relativeTo; + + //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() { + agent.SetNewDirection(newDirection.value, relativity.value, absolute.value, relativeTo.value.ToVector2()); + + if (setRawAsWell.value) { + agent.SetNewRawDirection(newDirection.value, relativity.value, absolute.value, relativeTo.value.ToVector2()); + } + + 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() { + + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs.meta b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs.meta new file mode 100644 index 0000000..53e15e2 --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewDirection.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: fd070de4d2cacf64b8c520e98c8e4138 \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewGravity.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewGravity.cs index 45bdc4b..4d90f8d 100644 --- a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewGravity.cs +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewGravity.cs @@ -2,16 +2,14 @@ using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; - namespace Reset.Units { - [Category("Reset/Movement")] [Description("Sets a new value for gravity. Additively, or absolutely.")] public class SetNewGravity : ActionTask{ - public BBParameter newGravity; - [Tooltip("Setting absolute to true will cause the current gravity to snap to the new gravity value. Keeping it false will make it apply additively to the current gravity. Both options use relativty for linear interpolation.")] + [Tooltip("Setting absolute to true will cause the resolved movement gravity to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement gravity. Both options use relativty for linear interpolation.")] public BBParameter absolute; + [Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")] [SliderField(0, 1)] public BBParameter relativity; diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs new file mode 100644 index 0000000..118300d --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs @@ -0,0 +1,49 @@ +using NodeCanvas.Framework; +using ParadoxNotion.Design; +using UnityEngine; + + +namespace Reset.Units { + + [Category("Reset/Movement")] + [Description("Set a new rotation value for this agent, either additively, absolutely, or relatively.")] + public class SetNewRotation : ActionTask { + public BBParameter newRotation; + [Tooltip("Setting absolute to true will cause the resolved movement rotation to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement rotation. Both options use relativty for linear interpolation.")] + public BBParameter absolute; + [Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")] + [SliderField(0, 1)] + public BBParameter relativity; + + public BBParameter relativeTo; + + //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() { + agent.SetNewRotation(newRotation.value, relativity.value, absolute.value, relativeTo.value); + 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() { + + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs.meta b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs.meta new file mode 100644 index 0000000..24fa7d6 --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewRotation.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 66d712031a5b8834c96bbf7bb79048fb \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs new file mode 100644 index 0000000..b8521ef --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs @@ -0,0 +1,47 @@ +using NodeCanvas.Framework; +using ParadoxNotion.Design; +using UnityEngine; + + +namespace Reset.Units { + + [Category("Reset/Movement")] + [Description("Set a new speed value for this agent, either additively, absolutely, or relatively.")] + public class SetNewSpeed : ActionTask { + public BBParameter newSpeed; + [Tooltip("Setting absolute to true will cause the resolved movement speed to snap to the new speed value. Keeping it false will make it apply additively to the resolved movement speed. Both options use relativty for linear interpolation.")] + public BBParameter absolute; + [Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")] + [SliderField(0, 1)] + public BBParameter relativity; + + //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() { + agent.SetNewGravity(newSpeed.value, relativity.value, absolute.value); + 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() { + + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs.meta b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs.meta new file mode 100644 index 0000000..9a2d700 --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/Movement Settings Changes/SetNewSpeed.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 605f812405d9b7d4c87c80ce8e41a056 \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs b/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs deleted file mode 100644 index 421a11d..0000000 --- a/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using NodeCanvas.Framework; -using ParadoxNotion.Design; -using Reset.Movement; -using Reset.Units; -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() { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs.meta b/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs.meta deleted file mode 100644 index 7d922f3..0000000 --- a/Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 8f32fe451feb2ca4e8159d4aa8919cd2 \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs b/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs deleted file mode 100644 index 76d9297..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs +++ /dev/null @@ -1,73 +0,0 @@ -using NodeCanvas.Framework; -using ParadoxNotion.Design; -using ParadoxNotion.Services; -using UnityEngine; - -namespace Reset.Movement { - - [Category("Reset/Movement")] - [Description("Process Y-axis movement for the agent")] - // TODO: Rename to UpdateGravitytDirection - public class UpdateGravityDirection : ActionTask{ - public BBParameter moveDirection; - public BBParameter jumpPower; - public BBParameter jumpPowerDecay; - - [Space(5)] - public BBParameter gravityAcceleration = 1f; - public BBParameter gravityMax = 8f; - - public BBParameter gravityPower; - - //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() { - MonoManager.current.onLateUpdate += LateUpdate; - 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() { - } - - //Called once per frame while the action is active. - protected override void OnUpdate() { - // Accelerate gravity - gravityPower.value += gravityAcceleration.value * Time.deltaTime; - gravityPower.value = Mathf.Min(gravityPower.value, gravityMax.value); - - // Apply a constant gravity if the player is grounded - if (agent.isGrounded) { - gravityPower.value = .1f; - } - - // Create the gravity direction - float gravityMoveDirection = jumpPower.value + Physics.gravity.y * gravityPower.value; - - // Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection - moveDirection.value = new Vector3(moveDirection.value.x, gravityMoveDirection, moveDirection.value.z); - - Debug.Log("Gravity Done"); - - EndAction(true); - - } - public void LateUpdate(){ - // Decay jump power - jumpPower.value = Mathf.Lerp(jumpPower.value, 0f, jumpPowerDecay.value * Time.deltaTime); - } - - - //Called when the task is disabled. - protected override void OnStop() { - - } - - //Called when the task is paused. - protected override void OnPause() { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs.meta b/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs.meta deleted file mode 100644 index 71e54df..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateGravityDirection.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 5531fbd949d33204690c98dd89a5e97f \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs b/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs deleted file mode 100644 index 8179295..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections; -using NodeCanvas.Framework; -using ParadoxNotion.Design; -using ParadoxNotion.Services; -using Unity.Cinemachine; -using Unity.Mathematics; -using UnityEngine; -using Reset.Movement; -using Reset.Units; - -namespace NodeCanvas.Tasks.Actions { - - [Category("Reset/Movement")] - [Description("Finalizes movement and sends the final move commands to the controller")] - // TODO: Rename to UpdateMovementDirection - public class UpdateMovementDirection : ActionTask{ - [ParadoxNotion.Design.Header("References")] - public BBParameter moveDirection; - // TODO: Remove this reference and let each copy of this use their own settings. - public BBParameter playerFacingDirection; - - [ParadoxNotion.Design.Header("Settings")] - public BBParameter accelerationSmoothing = 5f; - public BBParameter deaccelerationSmoothing = 5f; - public BBParameter deaccelerationCurve; - - public BBParameter directionChangeMinimumMagnitude; // Unused. Use to only make input change if it's over a certain input threshold. Maybe smoothing can affect this? - - private float lastLookMagnitude; - private Vector3 currentMoveDir; - - // References - private PlayerControls controls; - - //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() { - // Reference to controls - controls = agent.GetComponent(); - - 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(){ - // Initialize the smoothed direction with the value as is on input - // currentMoveDir = new Vector3(moveDirection.value.x, moveDirection.value.y, moveDirection.value.z); - } - - //Called once per frame while the action is active. - protected override void OnUpdate(){ - // Construct move direction - Vector3 targetDirection = moveDirection.value; - - // Get input value - Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y); - - if (inputMovement.magnitude < .1f) { - inputMovement = Vector3.zero; - } - - // Change how movement is managed based on facing state - switch (playerFacingDirection.value) { - case PlayerFacingDirection.TowardsTarget: - break; - case PlayerFacingDirection.MatchInput: // TODO: Recomment - // targetDirection = agent.transform.forward * inputMovement.magnitude; - targetDirection = inputMovement; - break; - case PlayerFacingDirection.MatchCamera: - targetDirection = Quaternion.Euler(Camera.main.transform.forward.DirectionTo(agent.transform.forward)) * inputMovement; // NOTE: This used to be t: currentRotSpeed * Time.deltaTime. - // See how it feels with a hard set value and go fro there. - break; - case PlayerFacingDirection.Static: - break; - default: - throw new ArgumentOutOfRangeException(); - } - - // Remove Y from variables - Vector3 targetNoY = new Vector3(targetDirection.x, 0f, targetDirection.z); - Vector3 currentNoY = new Vector3(currentMoveDir.x, 0f, currentMoveDir.z); - - // Smooth movement - if (targetNoY.magnitude > currentNoY.magnitude) { - currentMoveDir = Vector3.Lerp(currentMoveDir, targetNoY,accelerationSmoothing.value * Time.deltaTime); - - } else { - float deaccelValue = deaccelerationCurve.value.Evaluate(inputMovement.magnitude); - - currentMoveDir = Vector3.Lerp(currentMoveDir, targetNoY, deaccelerationSmoothing.value * Time.deltaTime); - } - - - currentMoveDir.y = moveDirection.value.y; - // Commit move direction - moveDirection.value = currentMoveDir; - // Debug.Log(moveDirection.value); - EndAction(true); - } - - // Gravity is processed in LateUpdate (added to MonoManager's onLateUpdate in OnInit()) - - - //Called when the task is disabled. - protected override void OnStop() { - EndAction(true); - } - - //Called when the task is paused. - protected override void OnPause() { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs.meta b/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs.meta deleted file mode 100644 index 2d2d345..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateMovementDirection.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 69daf571854fd8046a60a7baab64cc18 \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs b/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs deleted file mode 100644 index 0160aa9..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using NodeCanvas.Framework; -using ParadoxNotion.Design; -using UnityEngine; - - -namespace Reset.Movement { - - [Category("Reset/Movement")] - [Description("Updates the movespeed for this agent")] - public class UpdateMovementSpeed : ActionTask{ - public BBParameter target; - public BBParameter speed; - public BBParameter smoothing = 10f; - - private float currentSpeed; - - //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() { - if (!speed.useBlackboard) { - Debug.LogError("This Update Movement Speed does not have it's current value attached to a Blackboard variable. Nothing will happen.", agent.gameObject); - } - - 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(){ - // currentSpeed = speed.value; - - } - - //Called once per frame while the action is active. - protected override void OnUpdate(){ - currentSpeed = Mathf.Lerp(currentSpeed, target.value, smoothing.value * Time.deltaTime); - - speed.value = currentSpeed; - - if (Mathf.Abs(currentSpeed - speed.value) < .01f) { - - } - - Debug.Log("Speed Done"); - EndAction(true); - } - - //Called when the task is disabled. - protected override void OnStop() { - - } - - //Called when the task is paused. - protected override void OnPause() { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs.meta b/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs.meta deleted file mode 100644 index 34e234f..0000000 --- a/Assets/Scripts/Core/Graph Tasks/UpdateMovementSpeed.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 6a4c5896d783ad845861edd0c9eea14b \ No newline at end of file diff --git a/Assets/Scripts/Player/UnitMovementHandler.cs b/Assets/Scripts/Player/UnitMovementHandler.cs index 0692f03..7685772 100644 --- a/Assets/Scripts/Player/UnitMovementHandler.cs +++ b/Assets/Scripts/Player/UnitMovementHandler.cs @@ -211,18 +211,22 @@ namespace Reset.Units{ } public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new + Vector2 relativeValue = relativeTo + value; + if (absolute){ - resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, value, relativity); + resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, relativeValue, relativity); } else { - resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, resolvedMovement.moveDirection.World + value, relativity); + resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, resolvedMovement.moveDirection.World + relativeValue, relativity); } } public void SetNewRawDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new + Vector2 relativeValue = relativeTo + value; + if (absolute){ - resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, value, relativity); + resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, relativeValue, relativity); } else { - resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, resolvedMovement.moveDirection.RawWorld + value, relativity); + resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, resolvedMovement.moveDirection.RawWorld + relativeValue, relativity); } } @@ -235,10 +239,12 @@ namespace Reset.Units{ } public void SetNewRotation(Quaternion value, float relativity, bool absolute, Quaternion relativeTo = default){ // new + Quaternion relativeValue = relativeTo * value; + if (absolute){ - resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, value, relativity); + resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, relativeValue, relativity); } else { - resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, resolvedMovement.rotation * value, relativity); + resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, resolvedMovement.rotation * relativeValue, relativity); } }