This beginner friendly tutorial is about how to make two (or more) characters in Unreal Engine 4 move at the same time.
- Create a new Third Person Template project.
- You will need to create another character actor blueprints. Call it OtherCharacter. The parent for that class is Character. In the image, MainCharacter is the ThirdPersonCharacter blueprint.
- Create an array of OtherCharacters inside the ThirdPersonCharacter. I called mine AttachedObjects. Remember to click the grid next to the variable type to make it an array and click the eye icon to the right to make it editable when placed in the map. Creating an array will help in the future if we are making more than one character move along with the original ThirdPersonCharacter.
- Place the OtherCharacter into the map by dragging its blueprint onto the map.
- Select the ThirdPersonCharacter that is placed in the level and inside the details panel on the right of the editor, you should find a Default tab. Expand it and locate AttachedObjects. Add a new element to it. This element will be the OtherCharacter you placed in the level.
- Now it is time for the movement code. Inside the OtherCharacter blueprint, make four Custom Events and name them JumpPressed, JumpReleased, MoveForwards, and MoveRight. The ThirdPersonCharacter is going to call these events to handle input.
- Add two inputs, Direction (Vector) and Value (Float), to the MoveForwards and MoveRight custom event.
- Make a Jump node and connect it to JumpPressed, make a Stop Jumping node and connect it to JumpReleased, make two Add Movement Inputs and connect each of those to the MoveForwards and MoveRight custom events. Connect the Direction and Value inputs to the respective Add Movement Input nodes.
- In the ThirdPersonCharacter blueprint, we will call these four custom events to make all of the OtherCharacters move.
- Be sure to make Orientate Rotation to Movement true in Character Movement Rotation settings for the OtherCharacter. This will make the OtherCharacter look in the direction it is walking in.
There you go! You can make multiple OtherCharacters move at once by adding all of them to the AttachedObjects array in the ThirdPersonCharacter placed in the level. Be sure to also place the extra OtherCharacters in the level!
Thanks for reading!