Player Movement


Implemented movement for the player. The code was modified from the player movement script from a previous practical, implementing a basic eight-directional movement system that correctly animates the player based on the direction they're moving in.


Due to not having any diagonal-facing sprites designed, the animator on the player had to be modified slightly to ensure diagonal movement didn't look weird. When moving diagonally, the player always uses the left- and right-facing movement sprites regardless of the order the horizontal or vertical inputs were registered in.

In addition to correctly animating the player, the guns also had to be correctly animated to match the player's facing direction. Since the guns are separate sprites attached to the player, they were animated using a script that reads the player animator's X- and Y-inputs and applies them to the gun's animator.