Week 7 - Player Movement


Week 7 update DevLog – Player Movement

­This is the first update DevLog for Penguin Mania. This DevLog features player movement.

The player will be controlling Pablo the Penguin. Pablo was created from an animation spritesheet which is available from Game Art Guppy. It came with many animations including walking, jumping, sliding and many others. To start with, I created the walking, jumping and sliding animations. I also put together a basic platform just to demonstrate the animations and movement which I obtained from Kenney.



The walking animation of Pablo

 

The first step was to animate the players walking. I had to gather all of the sprites that correlated to the players walking animation. Next, I needed to set up the animation by putting the sprites in the correct order in the animation window and matching up the collider to fit properly every frame. After that, I had to create the jump animation. A similar approach was taken to do this in which I needed to put the sprites in order and set the collider up correctly. I decided then to start setting up the blendtree and actual movement of the player. First of all, to get a starting point, I started with a script from a previous practical. This had most of what I need to get my player to move left and right. I modified it to suit the platform game type rather than a top-down game. This required changing up the movement to only be on the horizontal axis. I then needed to edit and fix up my blendtree and put in all of the animations to match the movement. I also created a slide section in the blendtree as I will also need to incorporate the slide animation.

The next step was to correct the animation timing and duration, as well as the conditions for each animation. I had to tinker with this until I was happy with it all and got it to a point where it looks somewhat realistic and not buggy.



Pablo movement

 

After I had the walking animation and the player walking correctly, I implemented the slide animation. In the player movement script, I had to set up the animation to be shown when certain conditions are met which is when the S key is held down and the player moves to one side. I also updated this in the blendtree to match. At this point, the player was able to move and slide from one side to another using the A and D keys or the left and right arrow keys.

 

Pablo sliding animation and movement

 

The last step was to incorporate the jumping ability. I had a few challenges with trying to get it to work. The first thing I needed to do was add force to the rigidbody2d for the player to move upwards when a certain key is pressed down. I also needed to come up with a way of detecting the ground so that I can only jump when I am touching the ground and only walk and slide touching the ground and not in the air. I implemented this using a raycast to check if anything is underneath the player. I then incorporated this into the jump function as well as the walking and sliding animations so it would only show the animation if the player is grounded. When testing the jump animation, it was performing as it should so something needed to be changed. I needed to change the way the player moved. I needed to use Input.GetAxisRaw as something was interfering with the jump function. In the end, I was able to get the player to jump correctly instead of just teleporting upwards then dropping back down.



Pablo jumping animation and movement

Unfortunately, I had not achieved enough progress of the player movement in time to share and receive feedback in my tutorial. Some things that I think still need improving are some of the animations in which the jump animation is not shown when the player is moving left or right and jumping at the same time. Another issue is a glitch where if I continue to hold down the S key and move after the sliding animation has finished, it will continue to be in the sliding animation and just move around on its feet with no walking animation.


References

Penguin Platformer Game Character Sprites (2021). Image Available at: https://www.gameartguppy.com/shop/penguin/ (Accessed: 14 April 2021).

Kenney • Platformer Art: Winter (2021). Available at: https://www.kenney.nl/assets/platformer-art-winter (Accessed: 14 April 2021).

Leave a comment

Log in with itch.io to leave a comment.