Made player jumping more responsive

- Changed the input check in the jump function from a GetKeyDown() / GetKeyUp() to a GetKey() / !GetKey()
- This makes jumping a lot more responsive
- This also means holding the jump button causes the raccoon to "bunny hop" until jump button is released
This commit is contained in:
mushgunAX 2022-11-24 21:56:06 +08:00
parent c0f3720fd2
commit d6fab4439f
1 changed files with 2 additions and 2 deletions

View File

@ -285,7 +285,7 @@ public class PlayerController : Script
{ {
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE) if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE)
{ {
if (Input.GetKeyDown(Input.KeyCode.Space) && isGrounded && rb != null) if (Input.GetKey(Input.KeyCode.Space) && isGrounded && rb != null)
{ {
currentState = RaccoonStates.JUMP; currentState = RaccoonStates.JUMP;
Vector3 v = rb.LinearVelocity; Vector3 v = rb.LinearVelocity;
@ -304,7 +304,7 @@ public class PlayerController : Script
} }
} }
if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space))) if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || !Input.GetKey(Input.KeyCode.Space)))
currentState = RaccoonStates.FALLING; currentState = RaccoonStates.FALLING;
} }