Adding a controllable character to your level

Now you have a basic level setup. Maybe some walls, a floor to walk around. Let’s make a character class to explore the world you’ve made thus far.

 

First we’re going to set up the input keys in the project settings in the edit menu. We’ll do space to jump, and W/A/S/D to move forward/back/left/right. No mouse functionality yet but you can do that on your own if you wish by taking a look at the 3rd person demo project. 

Next we’re going to add our first two Blueprints. Go to the green Add New button and click Add Blueprint Class.

 

 

Add a GameMode class and a Character Class.

Let’s open up the Character Blueprint first. You can name yours whatever you’d like. We’ll go to the EVENT GRAPH tab first. First let’s add our “Events” for movement. An event is a red node with only one white arrow coming out of it. This is what triggers things to happen. In this case we want to trigger events for when the user presses W/A/S/D or the space bar.

Here you can see I made 3 events. One for jump, one for moving forward/back and one for moving left/right.

Make sure to connect the axis value (1 or -1 that we set up in Input) to the scale value and also be sure to set the direction. In unreal Z is up and down, X is forward/back and Y is left/right. So for ForwardAndBack event put a 1 in the X direction and leave the other two at 0. For Left and Right put a 1 in the Y value and leave X and Z at 0. Jump is easy as there is already a built in movement for that.

 

Now let’s go from the event graph tab to the VIEWPORT tab of our Character Blueprint. Add a camera so you can see and maybe some basic shapes to make your 3rd person character. Alternatively if you want your game to be first person, just add the camera where the eyes would be. A little above the arrow.

Lastly we need to set up our GameMode. This is easy. Just set your Default Pawn Class to be the character you just created. In my case I named my character DUDE. Then go in the World Settings tab of your level and be sure to set the GameMode Override to the GameMode you created. If you don’t see the World Settings tab you can find it in the top menu under the Window entry toward the bottom.