unreal-engine4unreal-blueprintunreal-development-kit

Shows mouse even after setting show mouse cursor Boolean to false


I made a pause widget that I open when I hit the 'P' screen: Opening pause on P blueprint

I will run you through what is happening in the blueprints:

  1. When the user presses the 'P' key
  2. Initiate the do once pre-defined functionality so that the user does not stack one pause screen over the other.
  3. Create the pause menu widget
  4. Add it to the viewport and make it a child of the play screen.
  5. 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?
  6. 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: Resume game button blueprint

In my resume game on clicked event blueprint:

  1. I am setting the paused game Boolean to false so that everything unfreezes.
  2. I am removing the current pause screen from the viewport.
  3. 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 >


Solution

  • 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