Two mechanics: pick up a key, then open a door — but only if you picked it up. That is deliberately tiny. The point is not the mechanic, it is everything you have to understand in order to write it: the class hierarchy, events, casting, variables, timelines and conditions. Once those six notions are in place, you write your own mechanics.
Setting up the project
We start from the plain Third Person template. First thing to fix if you are in France: the template keys are laid out for QWERTY. In the Content Drawer, Input folder, open IMC_Default, expand the IA_Move mappings and swap W for Z and A for Q.
- 1File ▸ New Level, pick a basic level — the template one is too heavy.
- 2Create a Project folder at the root of the content: your assets stay separate from anything coming in from FAB.
- 3Save the level inside it, then in World Settings, GameMode Override line, select the template’s Game Mode.
Without the GameMode Override, your new level launches with no character. It is what tells the level which pawn to spawn.
The class hierarchy, in four floors
This is the part most beginners skip, and the one that explains everything else. Every Blueprint class inherits from another: it takes what the parent knows how to do, and adds its own.
| Class | What it adds |
|---|---|
| Object | The mother class of all the others. It can hold Blueprint code: variables, functions. |
| Actor | Inherits from Object, and adds components — so a Static Mesh, a collision, a viewport. Anything that can exist in a level. |
| Pawn | Inherits from Actor, and becomes controllable. This is where the controller-related settings appear. |
| Character | Inherits from Pawn, and adds the collision capsule, the direction arrow and Character Movement — speed, jump, acceleration. |
For a key lying on the ground, you do not need a Character: nobody controls it. An Actor is enough — it carries a mesh and some code, which is all we are asking for.
The key: an Actor and a mesh
The asset comes from FAB, straight inside the editor. If the tab is missing, enable the FAB plugin in Edit ▸ Plugins and restart. Filter on free assets, add the key to the project.
Dropping the Static Mesh into the level directly gets you nowhere: a mesh cannot hold logic. That is the whole point of the Blueprint class — it is the one that can react.
- 1Create a Blueprint Class of type Actor, name it BP_Key.
- 2Add a Static Mesh component to it and assign it the key.
- 3Push its scale up to 10 so it reads clearly in the level.
- 4In the mesh details, set collisions to Overlap All: we want to walk through the key, while still knowing who walked through it.
The collision choice is the crux of the problem. With No Collision you walk through but nothing is detected. With Overlap you walk through **and** the event fires. That is exactly what we need.
Events: Begin Play, Tick, Overlap
An event is a starting point: Unreal calls it at a precise moment, and your code runs from there.
- Event BeginPlay — once, at launch.
- Event Tick — every frame. Handy for debugging, to be avoided for heavy logic: at 60 fps, your code runs 60 times a second.
- Event ActorBeginOverlap — as soon as another actor overlaps this one. The right one for a key you pick up.
Wire ActorBeginOverlap into Destroy Actor: the key disappears when you walk through it. But anything makes it disappear — a crate falling on it destroys it too.
Casting: only reacting to the right actor
The event provides an Other Actor output: whoever triggered the overlap. A Cast To BP_ThirdPersonCharacter node checks its type. If it succeeds, we carry on; if it fails, the Cast Failed output stays empty and nothing happens.
Casting does more than check: it gives access to the cast object. That output is how we will read from and write into the character — and it is what makes both mechanics possible.
In the character, create a boolean variable — call it HasKey. From the cast output, a Set node flips it to true on pickup. To check, a Print String wired to Event Tick shows its value in game: false, then true once you cross the key.
Making the pickup feel good
A key that vanishes instantly is not satisfying. Three additions are enough to change how it feels, and each one teaches a useful node.
Rotation first: the Rotating Movement component spins the key without a line of code. Its Rotation Rate can also be changed from the graph — pushing it from 50 to 900 on pickup gives a sharp acceleration.
Then the shrink. Set Relative Scale 3D drops the scale to zero, but brutally. It needs interpolating: a Lerp (Vector) node takes a value A, a value B, and an alpha between 0 and 1. At 0 it returns A, at 1 it returns B, in between it mixes.
Connector colour tells you the type: yellow for a vector, green for a float, red for a boolean. That is what tells you which Lerp to pick — here Lerp (Vector), since scale is a vector.
All that is left is to move the alpha over time: that is the Timeline’s job. One second long, a Float Track called Time, a point at 0 worth 0 and a point at 1 worth 1. Its output drives the alpha, and its Finished output finally triggers Destroy Actor.
A second Lerp wired to the same Timeline, this time into Set Relative Location with 300 on Z, lifts the key while it shrinks. And a Niagara system — a Fountain with Loop Behavior set to Once — added before the Timeline fires the particles at the right moment.
The door: same logic, one component more
The room and the door are modelled inside Unreal, without external software: Modeling mode, Cube Grid tool to carve out a room and leave an opening, Box tool for the door.
The generated meshes have no usable collision: open each of them and set Collision Complexity to Use Complex Collision As Simple. Not optimal in production, but immediate and good enough here.
The difference with the key comes down to one component. You do not walk through a door: you want it to react as you approach. A Box Collision, larger than the door, widens the actor’s detection area without being visible.
Uncheck Hidden in Game on that box while you tune it: you will see the zone in game and know whether it is too small or badly placed. Check it back afterwards.
- 1ActorBeginOverlap, then Cast To BP_ThirdPersonCharacter, just like the key.
- 2From the cast output, read the HasKey variable with a Get.
- 3Convert it into a Branch — right-click, Convert to Branch — or use a regular Branch node.
- 4On True, a Lerp (Vector) from 0 to 270 on Y, driven by a Timeline, slides the door aside.
- 5On False, wire nothing: with no key, nothing simply happens.
To close the door again, there is no need to duplicate the logic: the Timeline has a Reverse input that plays it backwards. Add the ActorEndOverlap event, the same cast, and wire it into Reverse.
What these two mechanics taught you
A key and a door, then. But along the way: which class to pick and why, which event answers at which moment, how to react only to the right actor, how to store a state in the character and read it back elsewhere, how to interpolate a value instead of snapping it, and how to place a condition.
That is enough to write a chest, a switch, a pressure plate or a lift without learning anything new. The only way to be sure is to close the tutorial and try.