wfmag.cc \ 35
Creating a jetpack in Unreal Engine 4
Toolbox
node. Select the new Branch node, drag out
from the True arrow, and search for another
branch. We also want to drag out from the False
arrow on the same node that we created from
the Sequence node and search for yet another
Branch node.
LIMITING FUEL
We’re going to add some float variables, so we
can set the maximum time the player can use
the jetpack, and another value that we’ll use
to track and compare that to. Think of this as
the amount of fuel the jetpack uses; when it’s
switched off, the fuel value will regenerate. As
before, click the + button next to the Variables
heading to the left of the blueprint window,
then move back over to the Details panel to set
up our variable. We’ll first change the Variable
Name field to something meaningful like maxFuel.
Make sure the Variable Type is still set to float
in our drop-down. We want to check the option
Instance Editable, as this will allow us to change
the fuel value inside the editor.
Finally, let’s set a default fuel amount. You may
note that the entry for the Default Value has
a message that requires a recompile. We can
simply do this by pressing the Compile icon on
the main Toolbar interface. You’ll then see a field
appear under the Default Value heading. I used
a value of 130, but you can play with this if you
want more or less air time.
Let’s create another new variable by using the
- button as before. In the Details panel, change
the Variable Name to currentFuel and make sure
we still have the float for the Variable Type.
We’ll now make sure that we use fuel when
we activate the jetpack, and that it regenerates
when it’s switched off. For this, move to the
branches that split from another branch node,
and focus on the one that attaches to the True
output. Select this branch and then left-drag
off the True arrow, search for IncrementFloat,
and add that node. We now repeat the process
with the branch attached to the False output
of the initial branch. Again, we select the True
arrow and left-drag out and this time search for
DecrementFloat. Right-click in an empty space
nearby, then search for Get Activate Jetpack
and place this node. We then attach the Return
Value from the Activate Jetpack node to our
Condition on the Branch that attaches to the
Then 1 node in our sequence. We can now focus
on the fuel variables we created. Move over to
the My Blueprint panel, select the FPS, maxFuel,
and currentFuel variables, and left-drag them
into the Event Graph and choose the Get option
for each.
We want to focus on the currentFuel variable
first, so left-drag from the yellow pin and search
for ‘greater than’ (or the > symbol), and select
the option that says float > float. The red pin
on this Greater Than node needs to then be
connected to the Condition pin of the Branch
node that is attached to the DecrementFloat
node. In effect, while the fuel is greater than
Using our variables, we’ll control
how much fuel the jetpack will
use and will regenerate.
The details panel for
the variables will let us
set not only the type
and default values for
variables, but what
category they will
appear in, or if the value
has min and max limits.