- Home /
Line renderer not showing up on client
In my game I am trying to spawn in a line to represent lasers being fired. My weapons call a Command spawn laser function, and pass in the points to spawn at. The player manager then spawns a gameobject with a line renderer component and uses SetPoints() to change the location of the line. The line shows up on the Host, but not the client- no mater who shoots the laser. My laser Game Object prefab has both a network identity, and transform, as well as is listed as a spawn-able prefab under the network manager.
[Command]
public void CmdSpawnLaser(Vector3 start, Vector3 end)
{
Vector3[] points = new Vector3[2];
points[0] = start;
points[1] = end;
GameObject _laser = Instantiate(laserGO_Sniper, start, Quaternion.identity) as GameObject;
_laser.GetComponent<LineRenderer>().SetPositions(points);
Destroy(_laser, .5f);
NetworkServer.Spawn(_laser);
}
(First post on unity answers- so sorry about any mistakes/things I should have added)
Answer by DatYak · Feb 19, 2018 at 08:34 PM
I solved It, I had to make an Rpc call and spawn the lines that way. [ClientRpc] public void Rpc_SetLineRenderPoints_MG (Vector3[] pts) { GameObject _laser = Instantiate(laserGO_MG, transform.position, Quaternion.identity) as GameObject; Destroy(_laser, .1f); _laser.GetComponent<LineRenderer>().SetPositions(pts); }
Your answer
Follow this Question
Related Questions
Raycasts in Multiplayer Network 0 Answers
Unity networking tutorial? 6 Answers
How to Sync List 1 Answer
Syncing/Instantiating a LineRenderer on Network 2 Answers
How to create a simple chat window 0 Answers