Hey everyone
I’m making a 2D-Platform game, everything was going well until I noticed 2 DIFFERENT problems regarding paused state (Time.timeScale = 0)
1) If I press ‘space’ while game is paused, player jumps right after I unpause (Time.timeScale = 1) the game.
For jump I use:
GetComponent<Rigidbody2D>.AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
I checked rigidbody’s info and indeed even if game is Paused, everytime I press ‘space’ velocity.y adds 5 and right after I unpause, my player performs the jump.
(Yes I can spam space and then do a super jump lol)
I don’t understand why my velocity can change while game is paused.
2) Player’s animation change while game is paused.
I’m using very simple animation system (2 states). ‘Idle’ and ‘Moving’.
They normally alter if my xmovement = Input.GetAxis(“Horizontal”)’ is equal or different to 0.
If I pause my game while xmovemenet is ‘1’, then if I press ‘left’ while game is paused, xmovement returns to 0 (that means my character returns to IDLE while paused). Same with the oppossite direction (-1 and right).
I have to mention 2 things about it:
-
While xmovement = 0, then it cannot change to 1 or -1 (while paused I mean). It only goes TO zero.
-
If I pause while xmovement = 0.49543234 (for example) then by clicking left it returns back to 0.
Sorry if my questions are simple, but I’m really confused not about how to find a ‘different’ way, but to find out why this is happening.
Thanks in advance