Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 9. Metal Mech Part 2 > Time for action — creating bullet collisions

Time for action — creating bullet collisions

Ok, now that we have all the images created, and the bullets have been brought to life with behaviors, we have to program in the bullet collisions.

  1. Let's double-click our Enemy actor, and create a new rule. Rename it to Destroy and change the settings to Actor receives event | overlaps or collides | with actor of type | Bullet.

  2. We want to add some health for these baddies. Under the attributes box of the Enemy actor, click the + button to create a new attribute, rename the attribute to Health, and change the value to 4, as shown in the following screenshot:

  3. Now, drag in a Change Attribute behavior, and change the settings to Change Attribute: | self.Health | To: | self.Health-1.

  4. What this will do is remove 1 health each time a bullet hits it. Easy enough, eh? Now, add in another rule, rename it to Die and change it to Attribute | self.Health | = | 0.

  5. Then, drag in a Destroy behavior.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial