Hello, I’ve just recently got the Network.Spawn to actually spawn what I need on all Clients before I realized that when spawning an objects on all connected clients(through [Command]), it still won’t show to a newly connected one.
I do register prefabs on Start() of the Player GameObject and I get no problems when spawning on connected players, when a player joins instead, he gets this until the object is destroyed:
Did not find target for sync message for 4 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
What am I doing wrong?
Command:
[Command]
public void CmdSpawnThrowable(Vector3 fwd, Vector3 pos, string name)
{
GameObject item = Instantiate(Resources.Load(name), pos, Quaternion.identity) as GameObject;
if (item.GetComponent<Collider>())
item.GetComponent<Collider>().isTrigger = false;
else
item.AddComponent<Collider>();
Rigidbody body = item.GetComponent<Rigidbody>();
if (!body)
body = item.AddComponent<Rigidbody>();
body.AddForce(fwd * 600 * body.mass);
NetworkServer.Spawn(item);
}
Call when Player presses a button:
if (isLocalPlayer)
CmdSpawnThrowable(player.transform.forward, player.righthand.transform.position, name);