top of page
Writer's picturejesskesson

2D game creation in Unity

Today we created a simple game in Unity, using simple sprites and mechanics. The game we made was a small moon lander game, where you control a spaceship from one platform to another with the spacebar and arrow keys.



We were given our own version of the game without any scripting done to it, and started by adding in a player sprite. We moved it above the first platform before starting to edit it. Since the ship needed to be able to land, we had to add on some legs. To do this, we added in parts of another sprite and moved them and sized them down. This gave the illusion of legs without any real changes to the sprite image. All that we had to do next was drag the 'legs' into the file of the ship sprite. This makes it so the ship is a parent to the legs, thus meaning they move when it moves.



The next thing we did was add a component to the ship sprite, and added a polygon hitbox around it. This makes it so if it collides with another object, it will stop. We then did the same to the legs.


The next step was to add functions to the sprite. The first thing we did was open the scripts folder in the bottom hot bar, and then into the movements folder. We then dragged the PushWithButton, which made it possible for the player to move up with space, and fall back down when not. And then the rotate function was added, which made it possible to turn the ship left and right.


We adjusted the settings to make it easier (turning down the gravity, make the functions less harsh). It ended up being fun to play, even though it was still impossible to die or win. It was fun to know how easy it could be to set up a game.


This is the script behind the RotateWithButton function. It's surprised me a bit with how simple it was, and how easy it would be to write.


There are private and public classes, which both correspond to different statistics in Unity. When editing the RotateWithButton function, you can change the speed of the spin. However, you can't change the actual spin.


It also scripts the buttons used to rotate the ship as public, so that they can be changed to other buttons if needed.


This is all we did today in Unity, but I enjoyed finding how simple it can be to create a simple game. I will use these skills in the future to help with game designing and creating.

3 views0 comments

Recent Posts

See All

Comments


bottom of page