Fix movement when moving on two axes at once
This commit is contained in:
parent
e188567fef
commit
84539db065
@ -67,8 +67,13 @@ public class PlayerController : MonoBehaviour {
|
||||
// Add player input momentum
|
||||
float TargetSpeed = MovementSpeed; // Tweak this to enable running or stuff
|
||||
Vector3 Move = transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal");
|
||||
// If Move magnitude is < 0, it's probably an analog stick, so scale target speed accordingly.
|
||||
TargetSpeed *= Mathf.Min(1, Move.magnitude);
|
||||
|
||||
if (Move.magnitude > 0) {
|
||||
Move.Normalize();
|
||||
if (Grounded) {
|
||||
// Slow down when moving on slopes
|
||||
TargetSpeed *= Vector3.Dot(Vector3.up, GroundNormal);
|
||||
}
|
||||
float CurrentSpeed = Vector3.Dot(Move, GroundVelocity);
|
||||
|
Loading…
Reference in New Issue
Block a user