PlayerVisual Customization

This commit is contained in:
2026-03-18 09:51:27 +01:00
parent 7058396d8e
commit 9d9d9ecb80
6 changed files with 195 additions and 126 deletions

View File

@@ -302,6 +302,9 @@ public class Player : MonoBehaviour
_state.Ground = currentGround;
_lastPlatformPosition = _state.Ground.position;
_lastPlatformRotation = _state.Ground.rotation;
_impulseForce.y = _platformVelocity.y = 0;
return;
}
@@ -342,9 +345,32 @@ public class Player : MonoBehaviour
private void SetGravity(float deltaTime)
{
if (_state.IsGrounded && _state.Velocity.y < 0)
{
_state.Velocity.y = STICK_FORCE;
}
else if (_persistentForce.y <= 0)
_state.Velocity.y = Mathf.Max(_state.Velocity.y + GRAVITY * deltaTime, MAX_GRAVITY);
{
if (_platformVelocity.y > 0)
{
_platformVelocity.y += GRAVITY * deltaTime;
if (_platformVelocity.y < 0)
_state.Velocity.y += _platformVelocity.y;
}
else if (_impulseForce.y > 0)
{
_impulseForce.y += GRAVITY * deltaTime;
if (_impulseForce.y < 0)
_state.Velocity.y += _impulseForce.y;
}
else
{
_state.Velocity.y += GRAVITY * deltaTime;
}
_state.Velocity.y = Mathf.Max(_state.Velocity.y, MAX_GRAVITY);
}
}
private void SetVelocity(float deltaTime)
@@ -398,19 +424,25 @@ public class Player : MonoBehaviour
private void SetMovement(float deltaTime)
{
Vector3 totalVelocity = _state.Velocity + _impulseForce + _persistentForce + _platformVelocity;
_references.Controller.Move(totalVelocity * deltaTime);
Vector3 velocity = _state.Velocity + _impulseForce + _persistentForce + _platformVelocity;
_references.Controller.Move(velocity * deltaTime);
// Decay impulse force
_impulseForce = Vector3.MoveTowards(_impulseForce, Vector3.zero,
_settings.ExtraForcesDrag * deltaTime);
Vector3 impulseForce = Vector3.MoveTowards(_impulseForce, Vector3.zero, _settings.ExtraForcesDrag * deltaTime);
impulseForce.y = _impulseForce.y;
_impulseForce = impulseForce;
// Decay inherited platform velocity — reset when back on ground
if (_state.IsGrounded)
{
_platformVelocity = Vector3.zero;
}
else
_platformVelocity = Vector3.MoveTowards(_platformVelocity, Vector3.zero,
_settings.ExtraForcesDrag * deltaTime);
{
Vector3 platformVelocity = Vector3.MoveTowards(_platformVelocity, Vector3.zero, _settings.ExtraForcesDrag * deltaTime);
platformVelocity.y = _platformVelocity.y;
_platformVelocity = platformVelocity;
}
}
private void SetState()