- When we have an animation consisting of one frame (i.e. our player’s idle animation) we are requesting a new frame each update step. Ideally, we only want to process the frame once.
- When we move the player diagonally no animation is played.
I’ve left myself a todo so as this may not be the most elegant way to accomplish what we want (but it does indeed accomplish what we want).
If you run the game you won’t notice anything different but don’t be disheartened because the game is now that bit more efficient.
Onto fix number two: no animation is played when we move diagonally. The reason for this is pretty simple, when you press a key it sets an animation state and to move diagonally you need to hold two keys (i.e. left and up), which means that each frame the controller is telling the animation component to set the state first to up (as an example) and then to left. When we transition to a new animation it is reset so the controller is resetting the animation each frame and nothing is being played.
This fix for this is to separate the logic for checking for key presses and calculating the animation state.