Networked linerenderer not visible on other players

Hi there,

I have the feeling that I’m missing something very basic. With I can’t find out what is wrong.

I have this script that shoots a simple beam (linerenderer). I want this beam to be visible on other player also. But it isn’t. RPC call is firing well, but line is only visible on firing client.

Any hints?

public class FireBeam : MonoBehaviour
{
    LineRenderer lr;
    PhotonView PV;

        // Start is called before the first frame update
    void Start()
    {
        lr = GetComponent<LineRenderer>();
        lr.enabled = false;

        PV = GetComponent<PhotonView>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Space) && PV.IsMine)
        {
            PV.RPC("RPC_Beam", RpcTarget.All, this.transform.position, new Vector3(this.transform.position.x, this.transform.position.y + 5));
        }
        else
        {
            lr.enabled = false;
        }
    }

    [PunRPC]
    public void RPC_Beam(Vector3 start, Vector3 end)
    {
        lr.enabled = true;
        lr.SetPosition(0, start);
        lr.SetPosition(1, end);
        Debug.Log("Beam!! " + start + " | " + end);
    }

Hi,

You probably already figured it out but in update you are constantly disabling the line for other players, I guess your problem comes from here.

Omg… :face_with_spiral_eyes: Sorry for wasting a page on the internet, if this is the issue… which it probably is… Thanks!!

Just a tip for anyone looking at this in 2023. Make sure you have a PhotonView on your object that has this script attached to it.