Moving left & right
This week I started to implement my games’ most basic mechanics, the players movement. I thought this would be a simple task but I found the Unity Playground material quite confusing as I don’t believe it was well explained. Instead I searched for help in tutorials on Youtube, I came across a great series by a content creator called ‘Blackthornprod’. At this point I did not have my character designed so I used one of the ones that were included in the original tutorial.
As I didn’t want my character to have the ability to double jump I only used this tutorial to get my player moving left and right. I found a different tutorial that helped me get my character jumping smoothly. It involved creating an invisible platform under my character that would detect when the player is touching the ground, if they are they have the ability to jump. This task was a lot more difficult that I had anticipated as, but thanks to the in-depth videos I was able to follow along closely.
As my game was going to split over multi-tiered levels I wanted the player to climb a ladder to get to the next level which be the next checkpoint in the case the player dies. To do this I followed another tutorial by ‘Blackthornprod’.
I couldn’t find any free ladder assets that would fit my dark theme so I made one in Illustrator using dark gradients.
In order for my player to climb the ladder I first had to make sure the player wasn’t in the middle of a jump before staring climbing. Then if the player was pressing the up button and touching a ladder the player would move up until they are no longer touching the ladder. The problem with this approach is that if the player lets go of the up key the character will not hold on and gravity will cause the character to fall back down. I used a piece of code from the tutorial to stop this from happening, which temporarily disables the gravity.
With my basic player control completed. I needed to create my levels and give my character somewhere to move. I found some further tutorials on 2D level creation and I preferred the method in the video below which involves using TileMaps, as it allows me to easily change my level design within Unity without having to edit a level in Illustrator/Photoshop.
The ’tiles’ used in this tutorial were also free assets but they were bright ‘Spring’ themed so I decided to edit them in Photoshop to better fit my own theme, the outcome is shown below.
This image was then imported in Unity where it was split into paintable squares called a TileMap. The most important setting when using TileMaps is to make sure that the TileMap has a ‘rigidbody’ assigned to it which will stop your character falling straight through it. Unfortunately the squares weren’t as seamless as I had hoped and you can see gaps or inconsistencies between some of them during gameplay. I also had issues with my character not being able to run up the slopes, I wasn’t sure how to fix this so I decided to not use them and stick to a more basic flat platform approach.