As the title says, when I click to Resume my game from the Pause menu, it also makes me Jump at the same time.
I’m using a Controller and obviously the “South Button” would be used to click on the pause menu buttons but it’s also used to “Jump” in game…
Is there anyway I can disable the Jumping when I click the “Resume Game” button on my Pause Menu?
Thanks.
I usually just make a float
timer to inhibit processing all forms of input for a moment after returning from the pause menu.
I’m new to coding, will you be able to show me what to write? Thanks.
This is one of those things that is EXTREMELY simple, but hooking it up is the tricky part.
Let me give you a few pointers.
First, just use a float.
private float inhibitInput;
Then where you go process the input in your Update() or FixedUpdate():
if (inhibitInput > 0)
{
// we're input-inhibited; count the timer down
inhibitInput -= Time.deltaTime;
return; // do not process any input now.
}
Now you need to hook up the dismiss button of your pause menu to somehow call this.
This gets into where to store the above number in the first place.
It could go in the character, but then pause has to reach into it.
It could go in the pause menu but the character has to reach into that.
This is how games end up with such a baffling array of many “manager” classes.
An “InputManager” or “GameManager” is really the one neutral place this could live: it knows when you press Pause / unpause, so it can set that inhibit value up and count it down.
The character can also query the input manager for ALL input, such that the character never even gets told there is input if it is inhibited.
And the input manager can count the timer down too.
Hopefully that gets you started and others can chime in here too.
Imphenzia: How Did I Learn To Make Games: