I made a pause widget that I open when I hit the 'P' screen:
I will run you through what is happening in the blueprints:
- When the user presses the 'P' key
- Initiate the do once pre-defined functionality so that the user does not stack one pause screen over the other.
- Create the pause menu widget
- Add it to the viewport and make it a child of the play screen.
- When I load the widget into the viewport show the mouse cursor (which works). However, for some reason I need to press it once to activate the pause screen window. I do not know why?
- Then I am setting the pause game to true to tell that the game has been paused and freeze everything. After that, I am resetting the do once functionality because the player will only interact with the pause screen now.
Next, I made a pause screen widget blueprint in which I have a button called "Resume" and this is the "On-Clicked" event of that resume button:
In my resume game on clicked event blueprint:
- I am setting the paused game Boolean to false so that everything unfreezes.
- I am removing the current pause screen from the viewport.
- Then I am turning off the show cursor. When this happens, I still see the cursor but when I click in the window, then the cursor disappears. I want the cursor to disappear when I hit the resume button and not when I click in the window once. It's acting as if the window has lost focus. So, when I hit the LMB in the window it disappears.
What is happening? Is this behavior normal in UE4? If so, will the game behave as expected after production and if not, how do I solve this problem?
For more information I am following this tutorial on Youtube: < https://www.youtube.com/watch?v=hP_J5rMikhg&list=PLKMRiZuSgt-7wY7hfUzg8JcuTFXAf85jv&index=12 >
By default the game set the input to GameAndUI but when you have this or UIOnly (on a widget), it's not possible to hide the cursor, so to do properly set the input to UIOnly when you show your pause menu and set to GameOnly before removing the widget and normaly you don't have to hide the mouse, this will hide automaticaly here a example: Go Game, Go Pause