Devlog 1: Player Movement


For the first devlog, we will focus on implementing player movement and feedback I got for the initial build.

To animate my player, I used an animation controller and blend trees. The animation controller switched between states depending on whether the player is idle on the ground or not. Blend trees were used to change the animation within each state based on the player’s horizontal direction. The direction of the idling animation depends on which direction the player was moving in before. These things were done in a player movement script based on an earlier class tutorial: the player’s state of movement was relayed to the animation controller using a Boolean, and the horizontal direction was relayed as a float. To create the animations, I first sliced a sprite sheet into multiple sprites. I then created animation clips for each scenario. A possible improvement would be to add animated wings to the player when flying.

To implement player movement, I modified a script from an earlier tutorial and added a Rigidbody2D to the player. The player can walk left and right, jump in those directions as well as up, and fly in all four directions. The walk/fly and jump speeds are public variables that can be changed through the inspector. The player moves in the direction of the pressed keys by changing the player’s horizontal or vertical velocity to the walk/fly speed (or vertical velocity to the jump speed if jumping). The player switches from walking to flying by double-jumping (which is checked with a simple timer). The player can switch back to walking by either double-jumping or landing on the ground (Rigidbody2D collision and no vertical velocity). When switching to flying, the gravity is changed to a much lower value. An alternative approach would have been to use forces on the Rigidbody2D instead of changing its velocity.

An example of the player walking and jumping

The feedback received from some members of the class could be summarised as "the movement felt good and the flight mechanic, while fun, could be improved". One member wanted the player to levitate when transitioning to flight so that you could choose direction then. Another said that having the player slowly descend during fight would be more realistic (then, the player would not descend in flight). Concerning levitation, I want to keep the initial flight direction the same as the previous walking direction as a smooth transition. However, I did change the flight so that there is a slow descent.

An example of the player flying after adjusting the flight


Files

Week 8 Feedback Build.zip 7.2 MB
Sep 08, 2023