From 10c5e5712dabed1715b88f38ddf7bffdce4f6733 Mon Sep 17 00:00:00 2001 From: Wizzard Date: Tue, 20 Jun 2023 20:24:53 -0700 Subject: [PATCH] Movment update again --- playtest/Assets/Scripts/PlayerController.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/playtest/Assets/Scripts/PlayerController.cs b/playtest/Assets/Scripts/PlayerController.cs index 07ec954..ce9bc31 100644 --- a/playtest/Assets/Scripts/PlayerController.cs +++ b/playtest/Assets/Scripts/PlayerController.cs @@ -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 } }