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. ...

Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.