After a lot of searching online, I have come here as a last resort for my problem.
The question says it all. How to sync a LineRenderer?
One answer I found was to use a ClientRpc. I tried it with no effect.
Below is the snippet of my code,
IEnumerator laserBeam()// This is called through another method on the click of a button
{
Beam = GetComponent<LineRenderer> ();
Beam.SetVertexCount (2);
Beam.material = BeamMaterial;
Beam.SetWidth (0.07f, 0.07f);
Beam.enabled = true;
Beam.SetPosition (0, gameObject.transform.position);
Beam.SetPosition (1, target.position);
RpcDrawLines (gameObject, target.position, true);
yield return new WaitForSeconds (1.0f);
Beam.enabled = false;
RpcDrawLines (gameObject, target.position, false);
}
[ClientRpc]
public void RpcDrawLines(GameObject start, Vector3 end, bool isOn)
{
LineRenderer beam = start.GetComponent<LineRenderer> ();
if (isOn) {
beam.SetVertexCount (2);
beam.material = BeamMaterial;
beam.SetWidth (0.07f, 0.07f);
beam.enabled = true;
beam.SetPosition (0, start.transform.position);
beam.SetPosition (1, end);
}
else
{
beam.enabled = false;
}
}
So, this is the code. Works fine on the Server but no effect in the client. I know I am doing something wrong in the client rpc. But I have no idea what it is. Any way of help would be appreciated. Thanks
Note: I am using UNET