Unity3D Bullet Tracers

864 views Asked by At

I'm currently working on implementing the elusive bullet tracer to my FPS. It isn't going so well.
a. The tracers align themselves off of the barrel of the Raycast area
b. They all aim themselves in the same direction, no matter where I point my cursor
This is the formula I'm currently using to calculate where the tracers should go.

        fwd.x += Random.Range(-accuracy, accuracy);
        fwd.y += Random.Range(-accuracy, accuracy);
        fwd.z += Random.Range(-accuracy, accuracy);
        Instantiate(tracer, transform.position, Quaternion.LookRotation((fwd - transform.position).normalized));

The code is Unityscript (js). Thank you!

1

There are 1 answers

1
maraaaaaaaa On BEST ANSWER

Quaternion.LookRotation((fwd - transform.position).normalized) needs to be Quaternion.LookRotation(fwd.normalized)