I’m trying to get my head around UNET, and I got stuck pretty much at the beginning.
I have basic scene:
- NetworkManager
- 2 spawn point (gameobjects with NetworkStartPosition) - so I’ll know which object is being “active” [one at 10,0,0 and the second at 0,10,0)
- player cube prefab with network identity and playerCube script.
This is the script on the player cube:
using UnityEngine.Networking;
public class PlayerCube : NetworkBehaviour {
void Start()
{
print("islocal? " + isLocalPlayer);
if (isLocalPlayer)
{
CmdPopulate();
}
}
[Command]
private void CmdPopulate()
{
print("CmdPopulate " + transform.localPosition);
}
}
When the editor is the host, then I get the logs of “islocal? true”; “CmdPopulate (0.0, 10.0, 0.0)”
and when the client connects I get the logs of “islocal? false”; “CmdPopulate (10.0, 0.0, 0.0)”
BUT when the editor is the client, then when he connects to the host, then the only logs are “islocal? true” & “islocal? false”
Why the command not being called the second time?? (tried with local player authority enabled\disabled, didn’t change)
I watched the live training, followed the “Setting up a Multiplayer Project from Scratch” in the manual, and search this forum and answers section, but none had the answer (or they did, and I just didn’t get it :/)
What am I missing here?