You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
96 lines
4.2 KiB
Plaintext
96 lines
4.2 KiB
Plaintext
Availability: Public
|
|
Title:Mouse Control Setup
|
|
Crumbs:%ROOT%, Resources, Resources/ContentExamples/MouseInterface
|
|
Description:How to set up a game for mouse control
|
|
|
|
[TOC(start:2 end:2)]
|
|
|
|
## Overview
|
|
|
|
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.
|
|
|
|
[REGION:note]
|
|
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.
|
|
[/REGION]
|
|
|
|
1. In the **Content Browser** (for sake of ease, use your Developer folder), **right-click** and choose **Blueprint** from the context menu.
|
|
|
|
[REGION:raw][/REGION]
|
|
|
|
1. In the **Pick Parent Class** window, use the Search bar to find the PlayerController class and click on it.
|
|
|
|

|
|
|
|
1. Name your new class **Mouse_PlayerController**.
|
|
|
|

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

|
|
|
|
1. 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**.
|
|
|
|

|
|
|
|
1. 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** from the context menu.
|
|
|
|
[REGION:raw][/REGION]
|
|
|
|
1. In the **Pick Parent Class** window, use the Search bar to find the GameMode class and click on it.
|
|
|
|

|
|
|
|
1. Name your new class **Mouse_GameMode**.
|
|
|
|

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

|
|
|
|
1. In the Game Mode category, click on the dropdown next to **Player Controller Class**. You should see the **Mouse_PlayerController** class created previously. Choose it from the list.
|
|
|
|

|
|
|
|
1. 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 **World Settings** button located in the toolbar. This opens up the World Settings in the **Details** panel.
|
|
|
|

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

|
|
|
|
1. 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.
|
|
|
|

|
|
|
|
|
|
|