PlayerVisual Customization
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user