Dust to Dust — Creating and Destroying Objects in Unity

Each enemy type and the lasers are all prefabs.
Behold, a Laser!
0.2 was used for the XYZ values.
Make sure you spell it correctly or Unity won’t understand that it is a prefab!
This means the object is prefabbed.
Here is how to save changes to your prefab!
  1. Be instantiated when we press the spacebar.
  2. Go up the screen at a set speed.
  3. Destroy itself once it goes out of the visible game area.
You can set the speed value to something else if you like.
Make sure it is public so you can set it inside of Unity.
You can watch the lasers spawn and despawn in real-time in the Hierarchy!



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
Jack Leavey

Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!