top of page
Writer's pictureZack Scanlon

getting started with unity.

After loading unity hub and creating a new project the first thing i did when inside my unity project was go into the asset store and download an asset pack called playground and once downloaded i imported it into my project file and now accessible in the project window of unity. Going into the image file in the project window and going further into the spaceship file has a spaceship that i can drag into my hierarchy to my game, this image/asset has an alpha channel that only allows to the spaceship to be seen since it has a value of one and the rest has a value of 0 in the RGBA channels. Using the same process to import a space background was easy however when i was imported both are sprites and having drawing problems so having the background selected and going into the inspector and the visibility and changing the sorting layer to background issue and putting the spaceship back on top. In order to give the spaceship movement and to be playable gong into the movement scripts and dragging and dropping the push script on the spaceship to allow it to have some movement however when you go into game mode and press play the ship just flies off so going back into scene mode and changing the gravity to zero to make sure it behaves properly as it is now a dynamic object. Next using the same method i dropped a rotate on to the spaceship as well. However now it moves off screen to fast using the camera follow script to keep track of it whilst it moves. Importing an asteroid and adding a 2D rigid body component with 0 gravity means i can add a collision object i played around with a box and circle collider for both of my assets however they don't give the accuracy need for a game like this so instead i used the polygon collider 2D to give me an accurate collision area using the alpha channels of my images/assets. With that added when i play and fly my spaceship they interact and hit and influence each others movement. Adding flames to make my spaceship more dynamic was achieved by dragging in a fire particle system and rotating and scaling it to my liking then positioning it on the booster at the base of my ship once positioned i parented the particle system to the spaceship by dragging the particle over the spaceship in my hierarchy to parent it.


 

Adding elements like the UI, health and winning were next, so first i started with adding a health system to my player which in this case is the spaceship next was addign a modify health component to the asteroid this would mean that when the player hits the asteroid it would actually subtract health instead of doing nothing when they hit once those system were in place the next logical thing to do was have a way to display this information to the play so using the UI prefab i dropped it into my hierarchy so this information can be displayed however to make sure unity knows what to display so going to the inspector tab for the spaceship and making sure to change the tag to player otherwise it won't display the relevant information for the players health. As a way to stand a chance of scoring points and winning having a shooting system, so the first step to doing that was using a projectile image and adding a capsule component then fine tuning the collision object to match the projectile then making sure to tick the "is trigger" box as this helps the object actually interacts with the physics system and doesn't intersect and actually collides. Then the bullet component was added to the laser object this helps unity keep track off who shoots what and who to give the points to. Once done i dragged and dropped the laser into my project window to make it a prefab and that it can be instanced multiple times. To make an emitter for the laser i spawned an empty and positioned it at the tip of the ship, then adding the object shooter to it and changing the X to zero so that when an object is emitted it is relative to the front of the spaceship. In the spawn section for the object shooter i put the laser prefab that i made in it. For the lasers to actually take effect and destroy the asteroid i had to add a "destroy for points" component this means when i shoot a laser the asteroid unity can add up how many points you have earned from destroying an asteroid, the worth of a singular asteroid can be determined within the "destroy for points" component you can make it worth any number of point you would like or you can have it worth none if you want the object of your game to be to about just destroying the asteroids. With these mechanics now set up designing a level would come next.



2 views0 comments

Recent Posts

See All

댓글


bottom of page