Before moving ahead, I want to give a quick rundown of what we are doing. We have an object with two animation states: idle and moving. Idle is the default mode. We have created an idle parameter with the checkbox checked, which makes the condition true.
In the next section, we will write a script that has the following two main functions:
- If the object is selected, it changes idle from true to false or vice versa
- In the update function, it checks for two conditions: whether idle is true or false and to play the correct animation
When the application loads, you will see the two boxes; because idle is the default state, nothing will happen until they are selected. Once they are, they will move. If they are selected ...