O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - tweak the hero

There are a few changes we should make to the HeroShip Script (formerly the Character Script) to suit our new game. Let's do it:

  1. Open the HeroShip Script.
  2. Delete the else if condition handling the steins. Get rid of everything in this snippet in bold:
    if(col.gameObject.tag == "bomb")
    {
    audio.PlayOneShot(explosionSound);
    Instantiate(explosion, col.gameObject.transform.position, Quaternion.identity);
    }
    else if (col.gameObject.tag == "stein") {
    animation.Play("catch"); // Ima catch that stein!
    }
    
  3. Shoot the Moon doesn't have beer steins, so we can safely kill this chunk.
  4. Delete all of the code controlling the character model animation. Get rid of this whole section in bold:
    if(lastX != transform.position.x) { Shoot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required