Instantiating & Destroying Gameobjects

To make our cube/player be able to shoot, we will add another game object and name it Laser. The laser will be made into a prefab which can be re used when called or instantiated.

Gameobjects that are shown as a bluebox are prefabs:

To Make our player shoot out the laser we will need to call it within our script so it knows what it is going to instantiate:

once this is done we can our prefab to the player within the inspector panel. we will then associate with calling this prefab by pressing the space key:

the new vector will give the a new position rather than the centre of the player which will then make it look more genuine.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store