Laser effect, LineRender & Raycast problem

!(http://[[/IMG] !(http://[[/IMG] !(http://[[/IMG] I try to make some laser cannons that rotate slowly until they point to enemy, and then fire laser.

There is strange missalignment that i dont know why.

When enemy moves away from the starting point, the misalignment happen.

When program start, 3 cannons point to enemy correctly.

LineRenderer LaserLine;
    int LaserRange = 50, RotateSpeed=2;
  
    // Use this for initialization
    void Awake() {
             
        LaserLine = GetComponent<LineRenderer>();
        LaserLine.SetWidth(0.1f, 0.1f);
        LaserLine.material = new Material(Shader.Find("Particles/Additive"));
        LaserLine.SetColors(Color.red, Color.red);
        LaserLine.enabled = false;

    }
 
    // Update is called once per frame
    void FixedUpdate () {

        Rotator();
          

    }

    void Rotator()
    {
        GameObject enemy = GameObject.Find("Enemy");

        Vector3 direction = enemy.transform.position-transform.position;
     
        Quaternion toRotation = Quaternion.LookRotation(direction);
     
        transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, RotateSpeed*Time.deltaTime);

        LaserLine.SetPosition(0, transform.position);

        LaserLine.SetPosition(1,direction);
             
        if (Physics.Raycast(transform.position, direction, 100)==true)
            LaserLine.enabled = true;
    }

](Photo Storage))](Photo Storage))](Photo Storage))

Line renderer works either in local space or world space
The fact that you have “SetPosition(0, transform.position);” suggests to me that you have it set in world position mode
So the second SetPosition should be the POSITION of the target, not the DIRECTION