change: number tweaks to grapple, some cleanup

This commit is contained in:
Chris
2025-08-31 11:58:10 -04:00
parent 29a608f298
commit f87c5a2cb7
3 changed files with 47 additions and 45 deletions

View File

@@ -64,20 +64,20 @@ namespace Reset.Units{
// public float value;
// }
// Debug viewing
[ShowInInspector, ReadOnly] private float outputSpeed;
[ShowInInspector, ReadOnly] private float additionalSpeed;
[ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
[ShowInInspector, ReadOnly] public Vector3 additionalMoveDirection;
[ShowInInspector, ReadOnly] private Quaternion outputRotation;
[ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
[ShowInInspector, ReadOnly] private float outputRotationSpeed;
//
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputSpeed;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float additionalSpeed;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 additionalMoveDirection;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion outputRotation;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputRotationSpeed;
// Used by graph to gradually shift into new values rather than dump them. Even if they're smoothed values they need to be eased into
[ShowInInspector, ReadOnly] private float outputJumpDecay;
[ShowInInspector, ReadOnly] private float outputGravityAccel;
[ShowInInspector, ReadOnly] private float outputGravityScale;
[ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedJumpDecay;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityAccel;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityScale;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
private float directionChangeDot;
private bool moveCallDisabledNextFrame;
@@ -225,7 +225,7 @@ namespace Reset.Units{
// Update the gravity, called every frame
private void UpdateCurrentGravity(){
// Accelerate gravity
data.gravityPower += outputGravityAccel * Time.deltaTime;
data.gravityPower += smoothedGravityAccel * Time.deltaTime;
data.gravityPower = Mathf.Clamp(data.gravityPower, Mathf.NegativeInfinity, data.gravityMax);
// Apply a constant gravity if the player is grounded
@@ -310,7 +310,7 @@ namespace Reset.Units{
// Add their related speeds
moveXZDir *= speed * Time.deltaTime;
moveYDir *= outputGravityScale * Time.deltaTime;
moveYDir *= smoothedGravityScale * Time.deltaTime;
addDir *= additionalSpeed * Time.deltaTime;
// Construct the direction and move
@@ -325,9 +325,9 @@ namespace Reset.Units{
}
private void SmoothingSettingsChanges(){
outputJumpDecay = Mathf.Lerp(outputJumpDecay, data.jumpPowerDecay, data.settingsChangeSmoothing * Time.deltaTime);
outputGravityAccel = Mathf.Lerp(outputGravityAccel, data.gravityAcceleration, data.settingsChangeSmoothing * Time.deltaTime);
outputGravityScale = Mathf.Lerp(outputGravityScale, data.gravityScale, data.settingsChangeSmoothing * Time.deltaTime);
smoothedJumpDecay = Mathf.Lerp(smoothedJumpDecay, data.jumpPowerDecay, data.settingsChangeSmoothing * Time.deltaTime);
smoothedGravityAccel = Mathf.Lerp(smoothedGravityAccel, data.gravityAcceleration, data.settingsChangeSmoothing * Time.deltaTime);
smoothedGravityScale = Mathf.Lerp(smoothedGravityScale, data.gravityScale, data.settingsChangeSmoothing * Time.deltaTime);
settingsChangeRotationSpeed = Mathf.Lerp(settingsChangeRotationSpeed, data.rotationSpeed, data.settingsChangeSmoothing * Time.deltaTime);
}
@@ -358,7 +358,7 @@ namespace Reset.Units{
private void UpdateGravityLate(){
// Decay jump power
data.jumpPower -= outputJumpDecay * Time.deltaTime;
data.jumpPower -= smoothedJumpDecay * Time.deltaTime;
data.jumpPower = Mathf.Max(0f, data.jumpPower);
}
}