Search Unity

Particle effect for raycast bullet trail.

Discussion in 'Scripting' started by MikawasakiDigital, Jun 15, 2019.

  1. MikawasakiDigital

    MikawasakiDigital

    Joined:
    Mar 29, 2019
    Posts:
    95
    Hey guys, I'm wondering if anyone could guide me in the right direction for a tutorial on adding a trail effect to my raycast bullets.

    I'm trying to get something like a smoke trail you'd see for bullets in games like Siege, Halo, COD, etc.

    Please if anyone could just throw me a bone and tell me where I can learn this it would be a blessing.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    One way is to keep a particle system on the muzzle of your gun, but disabled.

    When it's time to fire, enable the particle system, and start a coroutine and move the Particle system to the impact point during the next frame.

    The next frame would just turn it off and move it back to your gun muzzle.

    If the particle system is set to Rate Over Distance, it will leave you a nice stream of particles.

    You could also use a line-renderer if you want more of a laser-beam effect. You would set the points of the line renderer to your muzzle and the impact point, turn it on for one frame, then turn it off.
     
    MikawasakiDigital likes this.
  3. MikawasakiDigital

    MikawasakiDigital

    Joined:
    Mar 29, 2019
    Posts:
    95
    Update! I was able to figure it out thank you so much man.

     
    Kurt-Dekker likes this.