Time for action — blast the robots away
Our SentryBot
enemies get hurt by grenades, but let's have them pushed away from the explosion as well. In this section, we'll perform a simple position comparison to move them in the right direction, and then use our existing collision events to push them out of whatever objects they may end up stuck in.
1. In the event where we damage the
SentryBot
from a collision with theGrenadeExplosion
object, add a sub-event to check ifSentryBot.X
isLower than
the value ofGrenadeExplosion.X
2. Give this sub-event the
SentryBot
actionMove at angle
to move80
pixels at180
degrees.3. Finally, create another sub-event for when the opposite case occurs, and move the
SentryBot
by80
pixels at0
degrees. The event should match the following screenshot:
What just happened?
To finish off our game, we used a simple set of events to move the SentryBot
to the left or right of the explosion, as we had already put events in place to move the object out of the ground...