Bullet Trail for RayCast

Hey, I was wondering if someone could help me get a nice effect going that makes the raycast looking like its actually shooting something. Maybe a script or something would be nice? I am completely clueless as to where to start. Thank you in advance!

One easy way is to use a different approach. Use a basic rigidbody projectile to which you add force to project it.

Then you add a trail renderer. This way you have your bullet looking like one.

You still have the collision problem. You can fix it like this:

void FixedUpdate(){
   Linecast (previousPosition, currentPosition);
   previousPosition = currentPosition
}

This is simplified but the idea is that you linecast from the previous position to the actual position. If you have a collision you resolve it just like you do with raycast and stop trail renderer. If not the bullet continues.

The bonus of this approach, if you are dealing with long range, it gives a more natural curve to the bullet instead of going totally straight. This makes sniper shooting way much more realistic since you now have to aim above the target to shoot it (or adjust your rifle).