maint: removed all old unused tasks, created new tasks to replace them, cleaned up namespaces, reverted ItemTest.unity

This commit is contained in:
Chris
2025-09-26 15:20:42 -04:00
parent 4569cea664
commit ff7b04341b
22 changed files with 173 additions and 472 deletions

View File

@@ -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<UnitMovementHandler> {
[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<Vector3> feedNewRotation;
public BBParameter<Vector3> 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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 5132a76af4f722e49bc7fbbc75edcaf1

View File

@@ -3,7 +3,6 @@ using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;
using UnityEngine; using UnityEngine;
namespace Reset.Units { namespace Reset.Units {
[Category("Reset/Movement")] [Category("Reset/Movement")]

View File

@@ -1,10 +1,8 @@
using System;
using NodeCanvas.Framework; using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;
using UnityEngine; using UnityEngine;
namespace Reset.Units { namespace Reset.Units {
[Category("Reset/Movement")] [Category("Reset/Movement")]

View File

@@ -3,7 +3,6 @@ using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;
using UnityEngine; using UnityEngine;
namespace Reset.Units { namespace Reset.Units {
[Category("Reset/Movement")] [Category("Reset/Movement")]

View File

@@ -1,5 +1,3 @@
using System;
using Codice.Client.BaseCommands;
using NodeCanvas.Framework; using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;

View File

@@ -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<UnitMovementHandler> {
public BBParameter<Vector2> 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<bool> 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<float> relativity;
[Tooltip("Setting raw direciton will affect things that read the raw direction like rotation")]
public BBParameter<bool> setRawAsWell;
[Tooltip("This is set as a Vector3 but will be translated into a Vector2 on execute")]
public BBParameter<Vector3> 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() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fd070de4d2cacf64b8c520e98c8e4138

View File

@@ -2,16 +2,14 @@ using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using UnityEngine; using UnityEngine;
namespace Reset.Units { namespace Reset.Units {
[Category("Reset/Movement")] [Category("Reset/Movement")]
[Description("Sets a new value for gravity. Additively, or absolutely.")] [Description("Sets a new value for gravity. Additively, or absolutely.")]
public class SetNewGravity : ActionTask<UnitMovementHandler>{ public class SetNewGravity : ActionTask<UnitMovementHandler>{
public BBParameter<float> newGravity; public BBParameter<float> 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<bool> absolute; public BBParameter<bool> 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)] [SliderField(0, 1)]
public BBParameter<float> relativity; public BBParameter<float> relativity;

View File

@@ -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<UnitMovementHandler> {
public BBParameter<Quaternion> 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<bool> 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<float> relativity;
public BBParameter<Quaternion> 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() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 66d712031a5b8834c96bbf7bb79048fb

View File

@@ -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<UnitMovementHandler> {
public BBParameter<float> 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<bool> 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<float> 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() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 605f812405d9b7d4c87c80ce8e41a056

View File

@@ -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<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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 8f32fe451feb2ca4e8159d4aa8919cd2

View File

@@ -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<CharacterController>{
public BBParameter<Vector3> moveDirection;
public BBParameter<float> jumpPower;
public BBParameter<float> jumpPowerDecay;
[Space(5)]
public BBParameter<float> gravityAcceleration = 1f;
public BBParameter<float> gravityMax = 8f;
public BBParameter<float> 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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 5531fbd949d33204690c98dd89a5e97f

View File

@@ -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<CharacterController>{
[ParadoxNotion.Design.Header("References")]
public BBParameter<Vector3> moveDirection;
// TODO: Remove this reference and let each copy of this use their own settings.
public BBParameter<PlayerFacingDirection> playerFacingDirection;
[ParadoxNotion.Design.Header("Settings")]
public BBParameter<float> accelerationSmoothing = 5f;
public BBParameter<float> deaccelerationSmoothing = 5f;
public BBParameter<AnimationCurve> deaccelerationCurve;
public BBParameter<float> 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<PlayerControls>();
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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 69daf571854fd8046a60a7baab64cc18

View File

@@ -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<float> target;
public BBParameter<float> speed;
public BBParameter<float> 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 <b>Update Movement Speed</b> 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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 6a4c5896d783ad845861edd0c9eea14b

View File

@@ -211,18 +211,22 @@ namespace Reset.Units{
} }
public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
Vector2 relativeValue = relativeTo + value;
if (absolute){ if (absolute){
resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, value, relativity); resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, relativeValue, relativity);
} else { } 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 public void SetNewRawDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
Vector2 relativeValue = relativeTo + value;
if (absolute){ if (absolute){
resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, value, relativity); resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, relativeValue, relativity);
} else { } 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 public void SetNewRotation(Quaternion value, float relativity, bool absolute, Quaternion relativeTo = default){ // new
Quaternion relativeValue = relativeTo * value;
if (absolute){ if (absolute){
resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, value, relativity); resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, relativeValue, relativity);
} else { } else {
resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, resolvedMovement.rotation * value, relativity); resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, resolvedMovement.rotation * relativeValue, relativity);
} }
} }