O'Reilly logo

Unity Android Game Development by Example Beginner's Guide by Thomas Finnegan

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 – scripting the target

We only need one more piece before we can finish putting the target together.

  1. That piece is a script. Create a new script in our Scripts folder and name it Target.
  2. First, in order to interact with our state machine, we need a reference to the Animator component. It is the component that you removed from the tank and the city. The Animator component is what ties all of the pieces of animation together.
    public Animator animator;
  3. It is followed by two float values that will dictate the range of time, in seconds, that our targets will sit in their idle states.
    public float maxIdleTime = 10f;
    public float minIdleTime = 3f;
  4. Next, we have three values that will hold the ID numbers of the parameters that we need to change. ...

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