Movment update again

This commit is contained in:
Wizzard 2023-06-20 20:24:53 -07:00
parent 83f3af4baf
commit 10c5e5712d
1 changed files with 8 additions and 7 deletions

View File

@ -12,7 +12,8 @@ public class FPSController : MonoBehaviour
public float gravity = 20f;
public float lookSpeed = 2f;
public float lookXLimit = 45f;
public float airAcceleration = 2f;
public float airAcceleration = 8f; // Increased air acceleration
public float airFriction = 1f; // Added air friction
public float groundFriction = 6f;
Vector3 velocity = Vector3.zero;
@ -49,7 +50,7 @@ public class FPSController : MonoBehaviour
if (canMove)
{
float drop = velocity.magnitude * groundFriction * Time.deltaTime;
velocity *= Mathf.Max(velocity.magnitude - drop, 0) / velocity.magnitude; // Apply friction
velocity *= Mathf.Max(velocity.magnitude - drop, 0) / velocity.magnitude; // Apply ground friction
Accelerate(wishDir, speed, groundFriction); // Ground accelerate
@ -65,11 +66,11 @@ public class FPSController : MonoBehaviour
if (canMove)
{
// Air acceleration is now dependant on how aligned the move direction is with the current velocity direction
// The closer to straight ahead, the more acceleration, allowing for more maneuverability while keeping strafe speed under control
float currentSpeed = Vector3.Dot(velocity, wishDir);
float accel = airAcceleration * Mathf.Max(0, 1 - currentSpeed / speed);
Accelerate(wishDir, speed, accel);
// Apply air friction
float drop = velocity.magnitude * airFriction * Time.deltaTime;
velocity *= Mathf.Max(velocity.magnitude - drop, 0) / velocity.magnitude;
Accelerate(wishDir, speed, airAcceleration); // Air accelerate
}
}