When you are making a game, you might want to show and hide the mouse, so users can press buttons, and exit the game.
To get started, open a game in Unreal Engine, and open up the level blueprint. You can find it by going to blueprints, in the menu on the top, then press level blueprint. Right-click, and uncheck the box that says “Context Sensitive”. Once you do that, search for “set show mouse cursor”.

Duplicate this node, and also search for get player controller, and make two of that node. Connect the 2 get player controllers up to the target of the set show mouse cursor nodes. Set one of the set show mouse cursor nodes to yes, and the other to no.

At this point, these two functions will show the mouse, and hide the mouse. You could hook up one event to one of them, and another event to the other, for example you could hook up space bar to the first one, and enter to the other one. If you want one key to switch between showing and hiding the mouse, that is what I am going to do next.
The first thing that you need to do is get an event, for me, I am going to do spacebar. Next, search for branch. After that, search for get show mouse cursor, and hook that up to the condition for the branch. You will also need to hook a get player controller to the get show mouse cursor.

The next thing that you need to do is hook the true branch up to the node where you set show mouse cursor to false, and hook the true branch up to the node where you set show mouse cursor to true.

Now, your entire thing should work. Start your game, and when you press spacebar, it should show and hide.
You could also make a widget show when you show the mouse, and if you do that, you should make a node that says set input mode ui only, and when you close the widget, you should do set input mode gameplay only.

Leave a Reply

Your email address will not be published. Required fields are marked *