So I’ve been struggling to create some sort of way to create a bullet tracer effect.
I discovered the line renderer and it seems to be able to create the exact effect I want:

My problem is that I cannot for the life of me figure out how to make it start from my gun and fly towards my the hit.point of my raycast(s).
private GameObject bulletSprayPrefab; //Bullet Particle
void Start(){
bulletSprayPrefab = GameObject.Find("bulletTracer");
}
void ShootRay()
{
// Generate a random XY point inside a circle:
Vector3 direction = Random.insideUnitCircle / scaleLimit;
direction.z = z; // circle is at Z units
direction = transform.TransformDirection(direction.normalized);
foundHit = Physics.Raycast(transform.position, direction, out hit, 100); //Raycast
// GameVariables.clipSize--;
Instantiate(bulletSprayPrefab, spawnPoint.transform.position + direction, transform.rotation); //create particle
bulletSprayPrefab.GetComponent<Rigidbody>().AddForce(transform.forward * 100000);
}
This makes the line render appear as I have it created in the scene view, but of course just falls to the ground. I assume that it is creating one for every raycast there is mostly because I have not devised a way to determine a rate of fire for the weapon yet so these things are created quite quickly. (facing the wrong way, but they pour out of the barrel non-the-less)
ShootRay(); is called in Update with Input.GetMouseDown(0) if more of the class is needed just let me know.
EDIT/
(skip to 1:10 for the effect I’m trying to create.)
