Building the Fire Bullet Projectile Behaviors
Since our game uses a health bar, one thing we need to do is add and modify behaviors for the Fire Bullet projectile that was set up in the Adding a Shooting Behavior section.
Updating the DisappearOnCollision Behavior
The first change we're going to make is to the existing "DisappearOnCollision" behavior. To do this, select the Fire Bullet from the list of actors and click the Behaviors button to see the list of behaviors for the Fire Bullet, as shown in Figure 2-50.

Figure 2-50. Default behaviors for the Fire Bullet actor
By default, the "DisappearOnCollision" event is set to make both of the colliding actors disappear on a collision event. This is bad because it would make the Main actor disappear from the scene, which is not what we want. Instead, we want the Fire Bullet to disappear on a collision and we want to subtract the Health property for the Main actor.
To update the "DisappearOnCollision" behavior, click the Sender button (see Figure 2-50) and select the "Myself (the current instance of Fire Bullet)" radio button, as shown in Figure 2-51.

Figure 2-51. Updating the disappear behavior so that the current instance of the Fire Bullet actor disappears
Creating a Custom Code Behavior to Lower the Health Property
The next thing we want to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access