Unity Space Shooter – Chapter 6 – create laser prefab

Shot fire Object

A lot going on.

We create a game object called “Bolt” and add a child object(quad) called VFX.  We make this two parts so we can separate the logic from rendering.

  1.  Game Object  called “Bolt” This will be our primary shot object. The bolt object has movement(rigid body) and collision detection(capsule collider)
  2. Child Game object called VFX(quad) (transform rotate 90 to see)
  3. Create a material
    1. Go to material folder
    2. Create new new material and name it fx_bolt_orange
    3. Use the “select” picker to attach the texture of the bolt
    4. Select shading as mobile/particles/additive
  4. Drag and drop new material onto Quad
  5. Setup collision
    1. Remove “mesh collider” from VFX object(there by default)
    2. Go to Bolt and add component physics/capsule collider
      1. Adjust the size
      2. Change Direction to z-axis
    3. Select “isTrigger” checkbox to make it a “trigger collider”
    4. Attach a new Script called “Mover”

    5. see the new public “speed” set that on the Bolt object(20 is ok)
    6.  Test by playing.
    7. Move it to Prefab
    8. Test by playing and drag and drop as often as you want.

 

Create new Material

fx_bolt_orange