Player Movement


The player controls a bouncing ball. The first thing I did was to create my character that the player controls in Photoshop. I created a simple sprite sheet consisting of four tiles. There was a tile for the squashed animation when the player lands, a vertically squished ball, which is for when the character jumps, and the remaining two were it’s idle state. 

I created a game object in Unity and attached the sprite sheet that I created. I added a Rigidbody 2D with a Gravity scale of 1. This would make the player fall downwards after jumping. The sprite also has a Circle Collider 2D attached. I added a child object called ‘groundCheck’.  This child object contains a Circle Collider. The purpose of this is used in the Player Movement script for the animations. The Animator looks for this to flick into an Idle animation after landing. 

Then I moved onto animating the ball character. I split the sprite sheet into multiples, then spliced it.  I wanted the ball to go into a squash position when landing and a stretched position when jumping. The idea was that when the player jumps, the character will animate into the stretched position and then when they hit the ground, the character will squish. I ran into some issues with the animation states changing. When the jump button was pressed, the character would change states into the Jump animation and land in the squished position, however it wouldn’t transition back to the idle state.

I did some research on coding however, I wasn’t able to pin point where the issue was. I took my issue to a tutorial for feedback. With feedback in a tutorial, it was found that the code was written correctly. There was just an issue with my Transition from Land to Idle. When this was updated, the animator behaved correctly. 

The game behaves as it should (so far) in Unity, however when I built the WebGL, there seemed to be some glitching and flying in different directions.  This was given to me as feedback from my peers. I believe this might have had something to do with the Spawner. It is supposed to randomly spawn platforms that spin. This would explain why the ball would get thrown in different directions. For some reason, the platforms don’t show in the WebGL, but they still have a physical presence. Or it might be a bigger issue.

I’ll continue to work on this as I progress through the game. 

Movement in Unity



Movement Glitching in WebGl Build. 

Files

Archive 2.zip Play in browser
Apr 26, 2024

Leave a comment

Log in with itch.io to leave a comment.