change: all movement separated into invidividual tasks, a lot of shuffling value groups and related stuff around

This commit is contained in:
Chris
2025-09-16 17:07:20 -04:00
parent 7a0499f36a
commit aad8b78c22
17 changed files with 1507 additions and 1036 deletions

View File

@@ -1,82 +1,68 @@
using System;
using Reset.Core;
using Sirenix.OdinInspector;
using Unity.Cinemachine;
using UnityEngine;
public struct CameraSettingSingleValue<T>{
// NOTE: Could add a locked variable here if needed??
public T originalValue;
public T targetValue;
public float smoothing;
public struct SettingValue<T>{
public T value;
public float smoothing; // Smoothing changes how fast value is changed.
public float easing; // Easing changes how fast smoothing is changed, when given a new value.
public float currentSmoothing; // Actively eased and accessed value
public float currentValue; // Actively smoothed and accessed value
public T refVel; // For use with SmoothDamp
public float velocityRef;
public Vector2 velocityRefV2;
public Vector3 velocityRefV3;
public CameraSettingSingleValue(float defaultSmoothing = .2f, T original = default(T)){
originalValue = original;
targetValue = original;
public SettingValue(float defaultEasing = 2f, float defaultSmoothing = 1f){
easing = defaultEasing;
value = default;
smoothing = defaultSmoothing;
velocityRef = 0;
velocityRefV2 = default;
velocityRefV3 = default;
}
public void Reset(){
targetValue = originalValue;
currentSmoothing = 0;
currentValue = 0;
refVel = default;
}
}
public struct CameraSettingValues{
public CameraSettingSingleValue<float> mainFieldOfView;
public struct CameraSettingData : ICloneable{
public SettingValue<float> mainFieldOfView;
public CameraSettingSingleValue<Vector3> orbitPositionDamping;
public CameraSettingSingleValue<Vector3> orbitTargetOffset;
public SettingValue<Vector3> orbitPositionDamping;
public SettingValue<Vector3> orbitTargetOffset;
public CameraSettingSingleValue<bool> axisLookEnabledX;
public CameraSettingSingleValue<bool> axisLookEnabledY;
public SettingValue<bool> axisLookEnabledX;
public SettingValue<bool> axisLookEnabledY;
public CameraSettingSingleValue<float> axisLookGainX;
public CameraSettingSingleValue<float> axisLookGainY;
public SettingValue<float> axisLookGainX;
public SettingValue<float> axisLookGainY;
public CameraSettingSingleValue<float> orbitFollowTopHeight;
public CameraSettingSingleValue<float> orbitFollowTopRadius;
public CameraSettingSingleValue<float> orbitFollowCenterHeight;
public CameraSettingSingleValue<float> orbitFollowCenterRadius;
public CameraSettingSingleValue<float> orbitFollowBottomHeight;
public CameraSettingSingleValue<float> orbitFollowBottomRadius;
public SettingValue<float> orbitFollowTopHeight;
public SettingValue<float> orbitFollowTopRadius;
public SettingValue<float> orbitFollowCenterHeight;
public SettingValue<float> orbitFollowCenterRadius;
public SettingValue<float> orbitFollowBottomHeight;
public SettingValue<float> orbitFollowBottomRadius;
public CameraSettingSingleValue<Vector2> rotationComposerScreenPos;
public SettingValue<Vector2> rotationComposerScreenPos;
public CameraSettingSingleValue<Vector3> cameraOffsetOffset;
public CameraSettingValues(float defaultSmoothing){
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
axisLookEnabledX = new CameraSettingSingleValue<bool>();
axisLookEnabledY = new CameraSettingSingleValue<bool>();
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing);
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowCenterRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowBottomHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing);
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
public SettingValue<Vector3> cameraOffsetOffset;
public object Clone(){
return MemberwiseClone();
}
}
public class CameraSettingsProcessor : MonoBehaviour{
public static CameraSettingsProcessor Instance{ get; private set; }
public static CameraSettingValues values = new(defaultSmoothing: .2f);
[HideInInspector] public static CameraSettingData data;
[HideInInspector] public static CameraSettingData original;
[ShowInInspector] public static CameraSettingData smoothing;
[ShowInInspector] public static CameraSettingData easing;
[HideInInspector] public static CameraSettingData currentSmoothing;
[HideInInspector] public static CameraSettingData currentValue;
public static GameObject mainCamera;
@@ -102,87 +88,112 @@ public class CameraSettingsProcessor : MonoBehaviour{
offset = mainCamera.GetComponent<CinemachineCameraOffset>();
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
// Initialize camera settings values
values = new CameraSettingValues{
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
axisLookEnabledX = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[0].Enabled),
axisLookEnabledY = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[1].Enabled),
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[0].Input.Gain),
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[1].Input.Gain),
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, orbit.TrackerSettings.PositionDamping),
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .1f, orbit.TargetOffset),
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Height),
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Radius),
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Height),
orbitFollowCenterRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Radius),
orbitFollowBottomHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Height),
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Radius),
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing: .2f, rotComp.Composition.ScreenPosition),
};
}
void ProcessCameraValues(){
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef,
values.mainFieldOfView.smoothing);
// Initialize camera settings values from current values
data.mainFieldOfView.value = main.Lens.FieldOfView;
data.orbitPositionDamping.value = orbit.TrackerSettings.PositionDamping;
data.orbitTargetOffset.value = orbit.TargetOffset;
axisCont.Controllers[0].Enabled = values.axisLookEnabledX.targetValue;
data.axisLookEnabledX.value = axisCont.Controllers[0].Enabled;
data.axisLookEnabledY.value = axisCont.Controllers[1].Enabled;
axisCont.Controllers[1].Enabled = values.axisLookEnabledY.targetValue;
data.axisLookGainX.value = axisCont.Controllers[0].Input.Gain;
data.axisLookGainY.value = axisCont.Controllers[1].Input.Gain;
axisCont.Controllers[0].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[0].Input.Gain,
values.axisLookGainX.targetValue, ref values.axisLookGainX.velocityRef,
values.axisLookGainX.smoothing);
axisCont.Controllers[1].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[1].Input.Gain,
values.axisLookGainY.targetValue, ref values.axisLookGainY.velocityRef,
values.axisLookGainY.smoothing);
orbit.TargetOffset = Vector3.SmoothDamp(orbit.TargetOffset,
values.orbitTargetOffset.targetValue, ref values.orbitTargetOffset.velocityRefV3,
values.orbitTargetOffset.smoothing);
orbit.TrackerSettings.PositionDamping = Vector3.SmoothDamp(orbit.TrackerSettings.PositionDamping,
values.orbitPositionDamping.targetValue, ref values.orbitPositionDamping.velocityRefV3,
values.orbitPositionDamping.smoothing);
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef,
values.orbitFollowTopHeight.smoothing);
orbit.Orbits.Top.Radius = Mathf.SmoothDamp(orbit.Orbits.Top.Radius,
values.orbitFollowTopRadius.targetValue, ref values.orbitFollowTopRadius.velocityRef,
values.orbitFollowTopRadius.smoothing);
orbit.Orbits.Center.Height = Mathf.SmoothDamp(orbit.Orbits.Center.Height,
values.orbitFollowCenterHeight.targetValue, ref values.orbitFollowCenterHeight.velocityRef,
values.orbitFollowCenterHeight.smoothing);
orbit.Orbits.Center.Radius = Mathf.SmoothDamp(orbit.Orbits.Center.Radius,
values.orbitFollowCenterRadius.targetValue, ref values.orbitFollowCenterRadius.velocityRef,
values.orbitFollowCenterRadius.smoothing);
orbit.Orbits.Bottom.Height = Mathf.SmoothDamp(orbit.Orbits.Bottom.Height,
values.orbitFollowBottomHeight.targetValue, ref values.orbitFollowBottomHeight.velocityRef,
values.orbitFollowBottomHeight.smoothing);
orbit.Orbits.Bottom.Radius = Mathf.SmoothDamp(orbit.Orbits.Bottom.Radius,
values.orbitFollowBottomRadius.targetValue, ref values.orbitFollowBottomRadius.velocityRef,
values.orbitFollowBottomRadius.smoothing);
data.orbitFollowTopHeight.value = orbit.Orbits.Top.Height;
data.orbitFollowTopRadius.value = orbit.Orbits.Top.Radius;
data.orbitFollowCenterHeight.value = orbit.Orbits.Center.Height;
data.orbitFollowCenterRadius.value = orbit.Orbits.Center.Radius;
data.orbitFollowBottomHeight.value = orbit.Orbits.Bottom.Height;
data.orbitFollowBottomRadius.value = orbit.Orbits.Bottom.Radius;
rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition,
values.rotationComposerScreenPos.targetValue, ref values.rotationComposerScreenPos.velocityRefV2,
values.rotationComposerScreenPos.smoothing);
offset.Offset = Vector3.SmoothDamp(offset.Offset,
values.cameraOffsetOffset.targetValue, ref values.cameraOffsetOffset.velocityRefV3,
values.cameraOffsetOffset.smoothing);
data.rotationComposerScreenPos.value = rotComp.Composition.ScreenPosition;
data.cameraOffsetOffset.value = offset.Offset;
// And copy to the original
original = (CameraSettingData)data.Clone();
}
void Update(){
EaseToNewSmoothingValues();
ProcessCameraValues();
}
void EaseToNewSmoothingValues(){
data.mainFieldOfView.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, data.mainFieldOfView.easing * Time.deltaTime);
data.orbitPositionDamping.currentSmoothing = Mathf.MoveTowards(data.orbitPositionDamping.currentSmoothing, data.orbitPositionDamping.smoothing, easing.orbitPositionDamping.easing * Time.deltaTime);
data.orbitTargetOffset.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.axisLookGainX.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.axisLookGainY.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowTopHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowTopRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowCenterHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowCenterRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowBottomHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.orbitFollowBottomRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.rotationComposerScreenPos.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
data.cameraOffsetOffset.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
}
void ProcessCameraValues(){
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
data.mainFieldOfView.value, ref data.mainFieldOfView.refVel,
data.mainFieldOfView.smoothing);
axisCont.Controllers[0].Enabled = data.axisLookEnabledX.value;
axisCont.Controllers[1].Enabled = data.axisLookEnabledY.value;
axisCont.Controllers[0].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[0].Input.Gain,
data.axisLookGainX.value, ref data.axisLookGainX.refVel,
data.axisLookGainX.smoothing);
axisCont.Controllers[1].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[1].Input.Gain,
data.axisLookGainY.value, ref data.axisLookGainY.refVel,
data.axisLookGainY.smoothing);
orbit.TargetOffset = Vector3.SmoothDamp(orbit.TargetOffset,
data.orbitTargetOffset.value, ref data.orbitTargetOffset.refVel,
data.orbitTargetOffset.smoothing);
orbit.TrackerSettings.PositionDamping = Vector3.SmoothDamp(orbit.TrackerSettings.PositionDamping,
data.orbitPositionDamping.value, ref data.orbitPositionDamping.refVel,
data.orbitPositionDamping.smoothing);
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
data.orbitFollowTopHeight.value, ref data.orbitFollowTopHeight.refVel,
data.orbitFollowTopHeight.smoothing);
orbit.Orbits.Top.Radius = Mathf.SmoothDamp(orbit.Orbits.Top.Radius,
data.orbitFollowTopRadius.value, ref data.orbitFollowTopRadius.refVel,
data.orbitFollowTopRadius.smoothing);
orbit.Orbits.Center.Height = Mathf.SmoothDamp(orbit.Orbits.Center.Height,
data.orbitFollowCenterHeight.value, ref data.orbitFollowCenterHeight.refVel,
data.orbitFollowCenterHeight.smoothing);
orbit.Orbits.Center.Radius = Mathf.SmoothDamp(orbit.Orbits.Center.Radius,
data.orbitFollowCenterRadius.value, ref data.orbitFollowCenterRadius.refVel,
data.orbitFollowCenterRadius.smoothing);
orbit.Orbits.Bottom.Height = Mathf.SmoothDamp(orbit.Orbits.Bottom.Height,
data.orbitFollowBottomHeight.value, ref data.orbitFollowBottomHeight.refVel,
data.orbitFollowBottomHeight.smoothing);
orbit.Orbits.Bottom.Radius = Mathf.SmoothDamp(orbit.Orbits.Bottom.Radius,
data.orbitFollowBottomRadius.value, ref data.orbitFollowBottomRadius.refVel,
data.orbitFollowBottomRadius.smoothing);
rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition,
data.rotationComposerScreenPos.value, ref data.rotationComposerScreenPos.refVel,
data.rotationComposerScreenPos.smoothing);
offset.Offset = Vector3.SmoothDamp(offset.Offset,
data.cameraOffsetOffset.value, ref data.cameraOffsetOffset.refVel,
data.cameraOffsetOffset.smoothing);
}
}

View File

@@ -1,10 +1,8 @@
using System;
using NUnit.Framework.Internal;
using UnityEngine;
using ParadoxNotion.Design;
using PlasticPipe.PlasticProtocol.Messages;
using Sirenix.OdinInspector;
using UnityEngine.Serialization;
using Quaternion = UnityEngine.Quaternion;
public enum PlayerFacingDirection{
TowardsTarget = 0,
@@ -26,8 +24,7 @@ namespace Reset.Units{
// Movement Direction
public float accelerationSmoothing = 5f;
public float deaccelerationSmoothing = 5f;
// public AnimationCurve deaccelerationCurve; // Currently unused, may return
[SliderField(0,1)]
public float airDirectionDecay;
@@ -47,9 +44,8 @@ namespace Reset.Units{
public float settingsChangeSmoothing = 6f;
// Rotation
[ShowInInspector, SerializeReference]
public Enum rotateFacing;
[FormerlySerializedAs("rotationSpeedTarget")] public float rotationSpeed = 5f;
[ShowInInspector, SerializeReference] public Enum rotateFacing;
public float rotationSpeed = 5f;
public float rotationSmoothing = 1f;
public float rotationInputBlending = .3f;
@@ -57,8 +53,38 @@ namespace Reset.Units{
return MemberwiseClone();
}
}
public class ResolvedMovement{
public UnitMovementHandler.MoveDirection moveDirection;
public float moveSpeed;
public Quaternion rotation;
public float rotationSpeed;
public float gravity;
}
public class UnitMovementHandler : MonoBehaviour{
public struct MoveDirection{
private Transform owner;
private Vector2 moveDir; // Always local
public Vector2 World{
get => owner.TransformDirection(Local);
set{
moveDir = owner.InverseTransformDirection(value);
Local = moveDir;
}
}
public Vector2 Local{
get => owner.InverseTransformDirection(World);
set {
moveDir = value;
World = owner.TransformDirection(value);
}
}
}
// class MovementFloatModifier{
// // IBuffSource source
// public float value;
@@ -79,25 +105,24 @@ namespace Reset.Units{
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityScale;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
private float directionChangeDot;
private bool moveCallDisabledNextFrame;
private bool movedThisFrame;
// Lerps
private float directionChangeDotLerp;
private Vector3 moveSmoothVelocityRef;
private float gravitySmoothVelocityRef;
// References
private CharacterController controller;
private PlayerControls controls;
private LockOnManager lockOnManager;
private Vector3 moveSmooth;
public float gravitySmooth;
private bool relativeToCamera;
// Movement Data
[ShowInInspector, PropertyOrder(2)] public UnitMovementData data = new();
[ShowInInspector, PropertyOrder(2)] public UnitMovementData smoothing = new();
[ShowInInspector, PropertyOrder(2)] public UnitMovementData easing = new();
[ShowInInspector, PropertyOrder(2)]
public UnitMovementData data = new();
[HideInInspector]
public UnitMovementData defaultData;
[HideInInspector] public UnitMovementData defaultData;
[HideInInspector] public UnitMovementData defaultSmoothing;
[HideInInspector] public UnitMovementData defaultEasing;
void Awake(){
controller = GetComponent<CharacterController>();
@@ -105,15 +130,16 @@ namespace Reset.Units{
lockOnManager = GetComponent<LockOnManager>();
}
private void Start(){
void Start(){
defaultData = (UnitMovementData)data.Clone();
defaultSmoothing = (UnitMovementData)smoothing.Clone();
defaultEasing = (UnitMovementData)easing.Clone();
}
void Update(){
UpdateCurrentDirection();
UpdateCurrentGravity();
UpdateCurrentSpeed();
UpdateCurrentRotation();
DoMovement();
@@ -188,7 +214,7 @@ namespace Reset.Units{
float switchedDirection = Vector3.Dot(inputMovement, outputMoveDirection);
float switchedDirectionRemapped = Mathf.Lerp(0, 1, switchedDirection);
directionChangeDot = Mathf.Lerp(switchedDirection, switchedDirectionRemapped, 5f * Time.deltaTime) ; // turn that .5f into a variable
directionChangeDotLerp = Mathf.Lerp(switchedDirection, switchedDirectionRemapped, 5f * Time.deltaTime) ; // turn that .5f into a variable
// Smooth movement. Use deaccel smoothing if the input magnitude is lower, and accel smoothing if it's higher
// Also checks when grounded to only use Slerp on the ground
@@ -197,7 +223,7 @@ namespace Reset.Units{
slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
lerpedValue = Vector3.Lerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDot);
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDotLerp);
} else {
currentNoY = Vector3.Lerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
}
@@ -206,14 +232,14 @@ namespace Reset.Units{
slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.deaccelerationSmoothing * Time.deltaTime);
lerpedValue = Vector3.Lerp(currentNoY, targetNoY, data.deaccelerationSmoothing * Time.deltaTime);
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDot);
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDotLerp);
} else {
currentNoY = Vector3.Lerp(currentNoY, targetNoY, data.deaccelerationSmoothing * data.airDirectionDecay * Time.deltaTime);
}
}
// Commit move direction
outputMoveDirection = Vector3.SmoothDamp(outputMoveDirection, new Vector3(currentNoY.x, outputMoveDirection.y, currentNoY.z),ref moveSmooth , .5f *Time.deltaTime);
outputMoveDirection = Vector3.SmoothDamp(outputMoveDirection, new Vector3(currentNoY.x, outputMoveDirection.y, currentNoY.z),ref moveSmoothVelocityRef , .5f *Time.deltaTime);
}
// Update the speed, called every frame
@@ -237,7 +263,7 @@ namespace Reset.Units{
float gravityMoveDirection = data.jumpPower + (Physics.gravity.y * data.gravityPower);
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
outputMoveDirection.y = Mathf.SmoothDamp(outputMoveDirection.y, gravityMoveDirection, ref gravitySmooth, .1f * Time.deltaTime);
outputMoveDirection.y = Mathf.SmoothDamp(outputMoveDirection.y, gravityMoveDirection, ref gravitySmoothVelocityRef, .1f * Time.deltaTime);
}
// Update the rotation, called every frame
@@ -294,10 +320,6 @@ namespace Reset.Units{
public void DoMovement(){
DoMovement(outputMoveDirection, outputSpeed, data.gravityScale);
}
public void DisableNextMoveCall(){
moveCallDisabledNextFrame = true;
}
// Custom move from input
public void DoMovement(Vector3 moveDir, float speed, float gravityScale){