Unreal Engine 4 Blueprints Tutorial
In this Unreal Engine 4 blueprints tutorial, you will learn how to use blueprints to create a player character, set up inputs and make an item disappear when the player touches it. By Ricardo Santos.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Unreal Engine 4 Blueprints Tutorial
25 mins
- Getting Started
- Creating the Player
- Attaching a Camera
- Representing the Player
- Spawning the Player
- Creating a Game Mode
- Placing the Player Start
- Setting Up Inputs
- Axis and Action Mappings
- Creating Movement Mappings
- Axis Value and Input Scale
- Moving the Player
- Using Variables
- Getting the Player Direction
- Adding the Offset
- Frame Rate Independence
- Actor Collisions
- Enabling Collision
- Creating an Item
- Setting the Collision Response
- Handling Collision
- Placing the Item
- Where to Go From Here?
Creating an Item
Generally, an item is anything that the player can collect. You will use BP_Banana as the item.
To detect when the cube touches the item, you need an event node that triggers when there is a collision. You can use collision responses to generate such events.
A collision response also determines how an actor reacts when colliding with another actor. There are three types of collision responses: Ignore, Overlap and Block. Here is how they interact with each other:
Although you can use either Overlap or Block, this tutorial will only show you how to use Overlap.
Setting the Collision Response
Exit the game and then open BP_Banana. Select the StaticMesh component and then go to the Details panel. The Collision section is where you’ll set the collision response.
As you can see, most of the settings are greyed out. To make them editable, left-click the drop-down next to Collision Presets. Select Custom from the list.
Now, you need to specify the collision response between the item and the cube.
Components have an attribute called object type. The object type is just a convenient way to group together similar actors. You can read more about object types here.
Since the cube’s type is WorldDynamic, you want to change the collision response to that type. Under the Collision Responses section, change the collision response of WorldDynamic to Overlap. Do this by left-clicking the middle checkbox to the right of WorldDynamic.
Handling Collision
To handle collision, you need to use an overlap event. Go to the Components panel and right-click on StaticMesh. From the context menu, select Add Event\Add OnComponentBeginOverlap.
This will add the OnComponentBeginOverlap (StaticMesh) node to your Event Graph.
Finally, create a DestroyActor node and link it to the OnComponentBeginOverlap (StaticMesh) node. As its name suggests, it will remove the targeted actor from the game. However, since there is no target, it will destroy the actor that called it.
Placing the Item
Close the Blueprint editor and then make sure you are in the Blueprints folder.
Start placing bananas into the level by left-clicking and dragging BP_Banana into the Viewport.
Click Play and start collecting the bananas!
Where to Go From Here?
You can download the completed project here.
You are now one step closer to becoming an Unreal Engine expert. I hope this tutorial didn’t drive you bananas.
If you want to keep learning, check out the next post in the series, where I cover more about materials in Unreal Engine.