Linerenderer tilts when moving.

void Start()
rb = GetComponent();
mainCamera = FindObjectOfType();
void Update() {
movement = new Vector3(Input.GetAxis(“Horizontal”), 0f, Input.GetAxis(“Vertical”));
moveVelocity = movement * speed * Time.deltaTime;
Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
Plane groundPlane = new Plane(Vector3.up,;
float rayLength;

         if (groundPlane.Raycast(cameraRay, out rayLength)) {
             Vector3 pointToLook = cameraRay.GetPoint(rayLength);
             transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
         }private void FixedUpdate()
         rb.velocity = moveVelocity;

That was the movement script. This one is the laser-sight one.

void Start () {
         lr = GetComponent<LineRenderer>();
     void Update () {
         RaycastHit hit;
         if (Physics.Raycast(transform.position, transform.forward, out hit))
             if (hit.collider)
                 lr.SetPosition(1, new Vector3(0, 0,hit.distance * 3.2f));
             lr.SetPosition(1, new Vector3(0, 0, 300f));

The problem is that when the character moves the linerenderer is doubled. Almost like a trail. I have the video so you can understand better: 1

Please help. I really like coding and want to fix this but I couldn’t find a solution myself since I am a newbie and this is my first attempt on making a game.

No one can answer???