Player Movement and Shooting


Devlog One: Player Movement and Shooting

This is the first update devlog for my game "A Slime's Labyrinth". So far I have implemented player movement, animation, and player shooting. 


Player Movement:

In this game I have decided to go with 8-way movement, directed by the WASD keys, because this allows the player to have a large range of movement.  The code that I used to create this movement was very largely based on the code given in the UTas KIT109 tutorials. For this to work, I also had to add a rigidbody2D, with its gravity set to zero. This meant that when the game started it wouldn't just be pulled down and fall off the screen. I also added a polygon collider, but this will come in to play later when things to run into (like walls and enemies) are added in.


The Animation:

The way that I designed the sprite of the slime in order to show the direction of movement was very minimalistic, utilising the direction of its eyes to show where it was facing, rather than changing full body orientation. In total I created two body shapes for the slime, one was the original IdleSlime, and the other was the MovingSlime. I then either raised or lowered the eyes to give the illusion of heading up or down screen or flipped the sprite on its y-axis to create left and right. 

I then imported the sprite sheet, added an animator component, and created a blend tree with the sprites to make the slime change animation when the player moves about the screen.

Player Movement 


Player Shooting:

For PlayerShooting I decided to use the direction of the mouse, toggled by left click. To make this happen I needed to make it so that every time the mouse is clicked, the script calculates the direction of the cursor using vectors, then spawns in the slime ball with its velocity being the direction of the mouse multiplied by a set bullet speed. Overall, for players this just means that every time you left click, a slime ball will be shot towards your cursor. 

When shooting off the slime balls, another aspect that had to be taken into consideration was destroying the balls after a set amount of time. By doing this it ensured that there wouldn't be a million little green slime balls going on forever and slowing down the game.


Files

20240425 Slime'sLabyrinth.zip Play in browser
Apr 25, 2024

Leave a comment

Log in with itch.io to leave a comment.