for last few weeks I have been creating a 2D game inside of unity that uses collision, physics and movement speed all in different ways for the gameplay. I am going to show a step by step guide on how to create my game.
- unity interface
this is the first thing you see when you create a new unity project. this gives you the opportunity to name your project, save it to a certain folder and whether you want it to be 2D or 3D.
once you have created a new project in unity it will load a project, as you can see every new project comes with two ready built game objects Main Camera and Directional Light. the reason that we have these two game objects from the begging is that without them we wouldn’t be able to play the game at all as we won’t be able to see.
at the bottom there a folder called project, this is used to store all the important assets for the game like the scripts, sprites and even the actual scenes themselves. this means that its easy to find and use the assets you’ve added.
this is used to show you the properties of an game object like the name of the object and the positioning as well as allowing you to alter the object or even add new components to an object like CircleCollider2D that adds a collision circle around the object meaning that when it collides with an object that also has a collider that it’ll interact with it however you want it too.
there is also the console that is mostly used while your playing game as it can be used to keep a score, keep track of health or print a text in the console, you can pretty much code any text to appear in the console by writing a script. however, if you have miss coded something that prevents the game from working as intended then there will be an error in the console regardless whether you’re playing the game or not and it won’t allow you to play the game until the problem has been fixed. instead of it just saying what the error is an expecting you to fix it they tell you was part is missing so you can go to that specific line or sequences of code and alter it.
by using the project folder that I have previously mentioned to create a script by right-clicking and selecting create, C+ script which will open a new tab like the one above. once open the tab will have some script already written in it. these lines of scripts are just the basics code that most games will need to work. you can add new lines to the script to make your game do pretty much anything you can think off.
- setting up game objects
once you have come to grips with the layout of unity its time that you transfer your assets from your computer into unity. for this task, we were given the asset in a folder rather than having to create it ourselves so once we downloaded the folder all we need to do is drag and drop the needed assets into the project folder.
- rotating, scale, move game objects