How to simulate bullet tracer effects when using raycast hit

I am trying to simulate the bullet tracer effects seen on Uncharted Legacy with a particle system but it is not doing too good.

So how do I simulate bullet tracers?

//GM6 LYNX GM6 LYNX GM6 LYNXGM6 LYNX GM6 LYNX GM6 LYNX

          
if(hit.collider.gameObject == soldier_ani && Time.time >= timestamp)
     {
      
       
         ash.active=true;
      
        altcam.fieldOfView = 16.0f;
        //facelight.active=true;
           AnimRefObj.Play("firing_rifle");
         muzzash.gameObject.GetComponent<ParticleSystem>().Play();
         tracerash.gameObject.GetComponent<ParticleSystem>().Play();
        muzzash.GetComponent<AudioSource> ().Play ();
                zoomf.active = true;
                zoomi.active = true;
                soldier_ani.active = false;
                crouch.active = false;
      
      
      
timestamp = Time.time + timeBetweenShots;

Ray ray2 = new Ray(tipash.transform.position, tipash.transform.forward);

RaycastHit hit2;

    if(Physics.Raycast (ray2, out hit2, 10000)){
        //Soil
    if (hit2.collider.gameObject.layer == 19 && hit2.collider != null) {
         
          
Instantiate(exp50_soil, hit2.point, transform.rotation);
     }
     //Flesh
     if (hit2.collider.gameObject.layer == 15 && hit2.collider != null) {
         
          
Instantiate(exp50_flesh, hit2.point, transform.rotation);
     }
      //Wall
      if (hit2.collider.gameObject.layer == 20 && hit2.collider != null) {
      Instantiate(energy_burst, hit2.point, transform.rotation);
      Instantiate(exp50_stone, hit2.point, transform.rotation);
}}}
//GM6 LYNX GM6 LYNX GM6 LYNX GM6 LYNX GM6 LYNX

You have not explained anything, or stated your problem.

You also have not shown or explained your reference. Not everyone has played uncharted legacy, and no one should have to go out of their way to find out what you mean.

Problem aside, or lack-thereof, what I find extremely annoying about your project right now is the camera. It looks as if you parented the camera to one of the bones of the character, making it move far more than I, and I suspect everyone else, would like.

Try Trail Renderer

Pardon me for being lazy not explaining my problem but I found this old video that might work.

If any beginner wants to make tracer effects, this could work.

I just want to say I’ve been trying to find out properly about this problem myself and the trouble is that with that video it uses a pre-made script of some kind rather than actually detailing how to do it yourself. While there’s nothing necessarily wrong with this as it’s not locked behind a paywall of some kind you won’t be able to edit it later and so on to your liking or make adjustments because you don’t understand the code.

Okay, the audio for some reason was extremely quiet on this video but the code there looks to be the right sort of thing.

Hmmm -_-

Many of the tutorials on trail renderers simply don’t bother with raycasting which is quite infuriating.

1 Like

Ok after following the above examples, I finally got it working.

I just used a particle system with collision detection where when the tracer collides to a solid object, it expires.

Now I’ll be working on the Rocket trails for the RPG 7 the trail render should do it.

Just so you know to fix the lag on your recording try installing and running your recording software on a seperate hard drive.

Dude take a chill pill

9 Likes

he was just explaining what he did wrong and what he could’ve improved on! This is a formal forum so to be as effective as possible you have to be blunt which may come off as impatience or rudeness but I don’t really think it is

1 Like