Mouse Control Setup

How to set up a game for mouse control

Choose your operating system:

Windows

macOS

Linux

To make a game where you use the mouse cursor possible, there are a few things you must do when getting started. At a high level, the steps in Blueprint are as follows. We will cover them in greater detail below:

  • Create a new PlayerController Blueprint Class that enables the mouse cursor and any other desired mouse behavior.

  • Create a new GameMode Blueprint Class that utilizes your new PlayerController Class.

  • Set the World Settings to use your new GameMode in the Default GameType.

  • Use Blueprint scripting (either within the Level Blueprint or any Actor Blueprints) to process mouse interaction.

Creating a Custom Player Controller for Mouse Control

By default, the PlayerController class does not have mouse interfacing enabled. This is because not all games require a mouse cursor as their main form of interaction. Through the following steps, we will walk you through the creation of a custom PlayerController Blueprint Class that will allow you access to the mouse cursor.

Be aware that these are just the basic steps for enabling mouse control. In most cases, there will be others steps involved to customize your PlayerController and GameMode for the specific type of game that you are creating.

  1. In the Content Browser (for sake of ease, use your Developer folder), right-click and choose Blueprint Class from the context menu.

    CreateNewBlueprint.png

  2. In the Pick Parent Class window, use the Search bar to find the PlayerController class and click on it .

    PickParentClass_PlayerController.png

  3. Name your new class Mouse_PlayerController .

    MousePlayerController_CB.png

  4. Right-click on your new Blueprint in the Content Browser and choose Edit... . This will open up the Class Defaults window.

    EditDefaultsBlueprint.png

  5. In the Mouse Interface category, check all the options that apply to your project. This will likely include Show Mouse Cursor , Enable Click Events , and possibly Enable Mouse Over Events .

    MouseInterfaceProperties.png

  6. Save your new Blueprint.

Creating a Custom GameMode

Now that we have a PlayerController that has Mouse Input enabled, our next step is to create a custom GameMode that utilizes our new PlayerController. Note that the steps described here will not work if you have not yet created the custom Player Controller class as described above.

  1. In the Content Browser (for sake of ease, use your Developer folder), right-click and choose Blueprint Class from the context menu.

    CreateNewBlueprint.png

  2. In the Pick Parent Class window, use the Search bar to find the GameMode class and click on it .

    GameInfoParentClass.png

  3. Name your new class Mouse_GameMode .

    Mouse_GameInfoBlueprint.png

  4. Right-click on your new Blueprint in the Content Browser and choose Edit... . This will open up the Class Defaults window.

    EditDefaultsBlueprint2.png

  5. In the Classes category, click on the dropdown next to Player Controller Class . You should see the Mouse_PlayerController class created previously. Choose it from the list.

    SelectingPlayerControllerClass.png

  6. Save your new Blueprint.

Setting World Info Properties for Your Custom Game Mode

Now that we have our custom PlayerController and GameMode Blueprints completed, we just need to tell our World Settings to use them.

  1. Click the Settings button located in the toolbar. Then from the drop down select World Settings . This opens up the World Settings in the Details panel.

    WorldSettings.png

  2. In the Game Mode category, set the GameMode Override property to Mouse_GameMode , which we created earlier.

    WorldSettings_GameInfo.png

  3. When you play the map, you should now see the cursor. However, unless you have set up some sort of behavior (via C++ code or Blueprint), you will get no responses at this time. The image below was captured during PIE gameplay.

    MouseCursorInPlace.png

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss