When a weapon is fired, I want to draw a line for the bullet's trajectory.

I am using a LineRenderer to draw the trajectory with the code below:

    void FixedUpdate () {
        timer += Time.deltaTime;

        if (Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0) {
            Shoot ();

        if (timer >= timeBetweenBullets * effectsDisplayTime) {
            DisableEffects ();

    void DisableEffects () {
        gunLine.enabled = false;

    void Shoot () {
        timer = 0f;

        // Set first point
        gunLine.SetPosition (0, transform.position);

        shootRay.origin = transform.position;
        shootRay.direction = -transform.forward;

        gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);

I am using an orthographic camera in the scene. The line will show up but at certain rotations the line will partially render or be completely hidden. Oddly, the line will always render in the scene view-- the problem only exists in the game view.

Has anyone had this issue?


I don't really have answers for your problem but that might help you a bit.

Which version of Unity3D are you using ? Unity 5.5 beta contains an improved line rendered so you could actually fix your issue just by upgrading Unity.

See https://blogs.unity3d.com/2016/08/30/get-the-unity-5-5-beta-now/

Or you could try some assets like "Volumetric Lines" from Johannes Unterguggenberger which is a more advanced line rendering system.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.