Time for action – scripting the target
We only need one more piece before we can finish putting the target together.
- That piece is a script. Create a new script in our
Scripts folder and name it
- 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;
- 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;
- Next, we have three values that will hold the ID numbers of the parameters that we need to change. ...