Player Movement Devlog


Welcome to my first Devlog for Don't get Caught by the Cat. Here I will discuss the player movement mechanics of the game.

The movement for the game will be very simple. Each level is set out in a grid that represents a maze with only 90 degree turns and corridors of only one tile in width. Because of this level layout, the player is only required to be able to move in one direction at a time. The movement will be controlled with the following keys:

         W = up

           S = down

          D = right

          A = left

When a key is released the player will stop moving in that direction and if no keys are being pressed the player will become stationary.

To achieve this I used a RigidBody2D component with it's gravity scale set to zero and created a PlayerMovement script with some simple Booleans that represent which key is being pressed. Only one of these Booleans can be true at a time and they're set in the Update() function using Unity's Input.GetKeyDown() and Input.GetKeyUp() functions. These Booleans are then checked in the FixedUpdate() function and the Rigidbody2D's linearVelocity is set accordingly.


Once the player was moving I began animating it with this sprite sheet made by Sara Hollingsworth.


The first step I took was slicing the image into individual sprites and making an animation for each direction. Then using Unity's animator window I created a new blend tree state called walking. The blend tree uses two parameters xVel and yVel which are set in the PlayerMovement script as the RigidBody2D's linearVelocity components x and y.


The feedback I received in the tutorial testing session is that as the player is moving in a direction, for example right, and then moves left without releasing the D key, upon the A key being released the player should return to moving right. Another piece of feedback was that when the player stops moving they should keep facing in the direction they were going before they stopped. I aim to fix both of these issues in the near future.

Files

New folder.zip Play in browser
1 day ago

Leave a comment

Log in with itch.io to leave a comment.