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);
}