Scripting animations
Scripting is crucial in bringing our animations in sync with gameplay. Here, we’ll script our animations to respond dynamically to player actions, making our game more immersive and responsive.
With our player’s Animator Controller ready, it is time to do some scripting to make these parameters be affected by the actual behavior of the player and match the player’s. In this section, we will do the following to achieve this:
- Script shooting animations
- Script movement animations
Let’s start making our characters execute the Shoot animation when necessary.
Scripting player shooting animations
So far, we have created a behavior to shoot each time we press a key, but the animation is prepared for sustained fire. We can make our PlayerShooting
script shoot a bullet every X number of seconds while we keep the Fire key pressed to match the animation instead of having to press the key repeatedly.
By...