The first thing we did was create a new project using the version 2019.4.8f1. When it downloaded we went to the asset store and downloaded Playground to get everything we need to create our 2D game.
![](https://static.wixstatic.com/media/ca8399_d033f74c9f174131b013fdecd4d2fa61~mv2.png/v1/fill/w_232,h_272,al_c,q_85,enc_auto/ca8399_d033f74c9f174131b013fdecd4d2fa61~mv2.png)
To begin with, using the playground kit, we chose a background for the game. I chose a space theme starry scene and I set the sorting layer to Background, so everything else added will be in front of it.
![](https://static.wixstatic.com/media/ca8399_b445caa4ac5d414b99999b6963064025~mv2.png/v1/fill/w_643,h_370,al_c,q_85,enc_auto/ca8399_b445caa4ac5d414b99999b6963064025~mv2.png)
I then chose a spaceship for the game, there were 2 options a blue or red, I picked red, I dragged it into the hierarchy so that it gets placed right in the middle of the screen. I changed the gravity scale to 0 so that it doesn't move on its own when the game begins.
![](https://static.wixstatic.com/media/ca8399_be0fef35b7fd429baa1efedadc910d79~mv2.png/v1/fill/w_640,h_367,al_c,q_85,enc_auto/ca8399_be0fef35b7fd429baa1efedadc910d79~mv2.png)
After, in the Scripts folder I dragged the Push movement onto the Spaceship in the hierarchy, so when I play the game I can press the space bar to move forwards. Not only that, I also added the rotate movement from the same script folder.
![](https://static.wixstatic.com/media/ca8399_415f65346cee405b858b6fc4d3ff668e~mv2.png/v1/fill/w_144,h_95,al_c,q_85,enc_auto/ca8399_415f65346cee405b858b6fc4d3ff668e~mv2.png)
Unfortunately the camera doesn't move along with the spaceship, so I have to add a script called camera follow to the main camera in the hierarchy.
![](https://static.wixstatic.com/media/ca8399_369d7c88e5424227aae3493a4da2a393~mv2.png/v1/fill/w_435,h_738,al_c,q_85,enc_auto/ca8399_369d7c88e5424227aae3493a4da2a393~mv2.png)
Now I need to add an asteroid from the images file and add collision to both the spaceship and the asteroid say that they can interact with each other
![](https://static.wixstatic.com/media/ca8399_aa9dc056e895463597a6e2af52cef385~mv2.png/v1/fill/w_641,h_366,al_c,q_85,enc_auto/ca8399_aa9dc056e895463597a6e2af52cef385~mv2.png)
.I then added a flame to the bottom of the spaceship to make it look more realistic and has some actual movement to the spaceship. I dragged the asset of the flame from the hierarchy into the spaceship one so that it connects to it.
![](https://static.wixstatic.com/media/ca8399_e9dc3a15f331439a9f91bd2dc37123bc~mv2.png/v1/fill/w_456,h_382,al_c,q_85,enc_auto/ca8399_e9dc3a15f331439a9f91bd2dc37123bc~mv2.png)
I then added, from the attributes folder, a modify health script to the asteroid so that when I ad shooting to my spaceship it will damage the asteroid.
![](https://static.wixstatic.com/media/ca8399_dcd1ec181ab04b008c2487f20a09a336~mv2.png/v1/fill/w_202,h_169,al_c,q_85,enc_auto/ca8399_dcd1ec181ab04b008c2487f20a09a336~mv2.png)
Now I added a user interface from the Prefabs tab so the player will know more of what is happening in the game. (Health, Score)
![](https://static.wixstatic.com/media/ca8399_ea8eca343dc44fb08f866818a6053bad~mv2.png/v1/fill/w_980,h_390,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/ca8399_ea8eca343dc44fb08f866818a6053bad~mv2.png)
I even added a health system to the spaceship so if it gets hit by the asteroid it will lose health and when all the health is gone the game will end.
![](https://static.wixstatic.com/media/ca8399_05ea707b72b349ee8f9ea57a0ca69572~mv2.png/v1/fill/w_829,h_469,al_c,q_90,enc_auto/ca8399_05ea707b72b349ee8f9ea57a0ca69572~mv2.png)
I added in a medium laser on to the hierarchy, and changed the gravity to 0, I then added in the Bullet attribute to the medium laser so it acts like a spaceship gun.
![](https://static.wixstatic.com/media/ca8399_19b9c82bbe7f4916b57f0bec7defdd1f~mv2.png/v1/fill/w_161,h_129,al_c,q_85,enc_auto/ca8399_19b9c82bbe7f4916b57f0bec7defdd1f~mv2.png)
I then dragged the asset for the laser into the prefab ad deleted it from the hierarchy. I then created an empty asset which I gave the object shooter to and put the on the side of the spaceship, then duplicated it and put it on the other side.
![](https://static.wixstatic.com/media/ca8399_2a5f3a6e459640e39080ccf2ba384a20~mv2.png/v1/fill/w_293,h_249,al_c,q_85,enc_auto/ca8399_2a5f3a6e459640e39080ccf2ba384a20~mv2.png)
That's pretty much all of it. Unfortunately I can't see the lasers when I shoot, but they still work as the asteroid moves when I aim at it and press the fire button.
Comments