34 / wfmag.cc
Creating a jetpack in Unreal Engine 4
Toolbox
Navigate the content browser to find assets and
blueprints for use in your game project.
FirstPersonCharacter blueprint window. First,
change the default Variable Name to Activate
Jetpack. We then verify that the drop-down
under the Variable Type is set to the default
Boolean. Now we’ve created this, move back to
the Event Graph and find our InputAction Jump
node, then select the arrow next to the words
Pressed. If we left-drag
out from this arrow, we
can then search for Set
Activate Jetpack, which
is our variable. We now
repeat the process for
the arrow next to the word Released. You should
see a little checkbox on both these nodes –
check the one attached to the Pressed output.
When pressed, we’re activating our jetpack, so
the boolean value is true.
Right-click in an empty space, search for Event
Tick, and place the node; the event tick will run
our code every frame. While this is fine, we want
our code to be frame rate independent so the
jetpack will work the same, even with lower or
higher frame rates. To achieve this, we’ll store
our frame rate. First, we’ll add another new
variable, so back on the left-hand panel, click
the + symbol next to where it says Variables. In
the right-hand Details panel, we set the Variable
Name to FPS and then change the drop-down
for the Variable Type to float. Next, move back to
the Event Graph and select the arrow pointing
right on the Event Tick node. If you hover over
it, you’ll see the word Exec, as this will execute
next in our chain. Left-
click and drag from this,
then search for our FPS
variable, and pick Set
FPS. We now right-click
in an empty space close
to the Event Tick node and search for ‘division’
(or the / symbol), and then pick the option listed
as float / float. Now select the type-in for the top
left of the division node and replace 0.0 with
the value of 1.0. We then set the other value
by dragging from the Delta Seconds pin on our
Event Tick node to the bottom of our division
node; you’ll know when it’s working because
a green tick will appear. We then connect the
return value pin – the one on the right-hand side
of the division node – to the pin labelled FPS on
the Set FPS node.
Focusing on our Set FPS node, select the Exec
arrow, left-click and drag from this, and then
search for a Sequence node and place it. Next,
left-drag from the sequence node on the first
arrow labelled Then 0, and search for a Branch
node. Now right-click in an empty space and
search for Get Activate Jetpack, and place the
variable node. We then drag out from the red
pin on our Activate Jetpack node and connect
this to the Condition node of the branch. Move
back to the Sequence node, and drag out from
the Then 1 arrow and search for another Branch
A wide selection of
templates are available
to help you get started
on your projects.
LOGIC FLOW
Branches are essentially an if
statement. We can evaluate
the values coming in and make
decisions if we meet criteria
based on them. This can result
in the route that the logic flow
will take in our blueprint code.
“We can set the
maximum time players
can use the jetpack”