Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Unity Game Development Blueprints
  • Toc
  • feedback
Unity Game Development Blueprints

Unity Game Development Blueprints

By : John P. Doran
4 (6)
close
Unity Game Development Blueprints

Unity Game Development Blueprints

4 (6)
By: John P. Doran

Overview of this book

If you want to build enticing projects with Unity, this book is for you. Readers who are familiar with the basics of how to create simple projects in Unity will have an easier time.
Table of Contents (11 chapters)
close
10
Index

Damaging and killing enemies


Now that we have enemies moving towards us, we need some way for them to be damaged and killed! Let's do that now by performing the following steps:

  1. The first thing we need to do is make it easy to get a reference to all of our enemies, so let's add a tag by going to the Inspector tab and navigating to Tag | Add Tag…. Once the Tag & Layer menus come up, type in Enemy into Element 0. Then go back into the Ghost_mesh child object, add the Enemy tag to it, and rename the parent object to Ghost:

  2. Next, let's dive back into MonoDevelop, edit our PhoneBehaviour script, and add the following code in bold to its Update function:

      // Update is called once per frame
      void Update () {
        if (Input.GetMouseButtonDown(0) && Input.GetMouseButton(1))
        {
          StartCoroutine(CameraFlash());
    
          GameObject[] enemyList = GameObject.FindGameObjectsWithTag("Enemy");
    
          foreach (GameObject enemy in enemyList)
          {
            if(enemy.renderer.isVisible)
        ...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete