fixed movement

This commit is contained in:
maxwes08
2025-10-07 10:37:46 +02:00
parent bd2c87ddd1
commit 7835ade2c1
6 changed files with 91 additions and 30 deletions

View File

@@ -19,8 +19,8 @@ namespace Voxel
private float _gravity = 0.08f;
private float _terminalVelocity = -3.92f;
private float _airMultiplier = 0.98f;
private float _groundMultiplier = 0.91f;
private float _airMultiplier = 0.91f;
private float _groundMultiplier = 0.6f;
private const float COLLISION_EPSILON = 0.01f;
@@ -46,7 +46,9 @@ namespace Voxel
if (!OnGround)
{
Vector3 acceleration = new Vector3(0, -_gravity, 0);
Velocity = (Velocity + acceleration) * _airMultiplier;
Velocity += acceleration;
Velocity *= _airMultiplier;
if (Velocity.Y < _terminalVelocity)
{
@@ -55,11 +57,7 @@ namespace Voxel
}
else
{
Velocity = new Vector3(
Velocity.X * _groundMultiplier,
0f,
Velocity.Z * _groundMultiplier
);
Velocity = new Vector3(Velocity.X * _groundMultiplier, 0f, Velocity.Z * _groundMultiplier);
}
UpdateOnGround();