Game Development Reference
In-Depth Information
Fruits blueprints
I mentioned before that all of the fruits share the same logic, so in this step, I'll be showing
you how to build one of the fruits, and then you can easily reconstruct or duplicate the rest
of the fruits blueprints within a few seconds.
As we discussed how to build a multicomponent blueprint in
Chapter 3
,
Creating a Brick
Breaking Game
, you need to make the fruit actor blueprint out of three components: the
Projectile Movement
component, the
Sphere
component as a collider, and the
PaperS-
prite
component, which will hold the art asset for the fruit. However, keep in mind that this
time the
Projectile Movement
component should follow gravity, so make sure that
Pro-
jectile Gravity Scale
is set to
1.0
.
On
Event Begin Play
, you need to define that this blueprint can get even swipe inputs, so
you need to add the
Enable Input
node and connect it to the
Get Player Controller
node.
And since the game has only one player, you can leave
Player Index
set to
0
as it means
the first player in the player array.
To interface a touch, get over the fruit (swipe); it is a little tricky. As the engine does not
have swipe functionality right now, all we need is to just detect the moment when a finger
moves over a fruit. So we will calculate it as a touch enter event by using the node
OnIn-
putTouchEnter
or
EventTouchEnter
on later editor builds and set
FingerIndex
to
Touch
1
from the enum of touches.
If you were not able to find the enum of touches node, that means you are running a higher
editor build. In that case, the easiest way to get a similar result is by looking for a node
called
Equal(Byte)
, which is usually inside the
Byte
section of the
Math
node. This will
give the same result but using numbers directly instead of enums.
Search WWH ::
Custom Search