Hi there.
So i’ve implemented multiplayer on my game and so far, everything is working fine.
Only problem right now is to sync the movement on both host and client.
I got 2 prefabs. Both of them have network identity (local player authority) and network transform.
- Player prefab that is set on the Network Manager.
- Worker prefab is set in Registed Spawnable Prefabs.
At the start of player script, I have:
void Start()
{
hud = GetComponentInChildren<HUD>();
AddStartResourceLimits();
AddStartResources();
if (isLocalPlayer)
{
CmdSpawnThings();
}
}
[Command] //Calls server to do something
void CmdSpawnThings()
{
GameObject instance = Instantiate(workerPrefab, transform.position, transform.rotation) as GameObject;
instance.transform.parent = transform;
//NetworkServer.Spawn(instance);
NetworkServer.SpawnWithClientAuthority(instance,base.connectionToClient);
//RpcSetParent(instance);
}
I’m not sure if i’m missing anything to get this to work, but moving the worker in the client doesnt update it’s location on the host.
I’ve seen several tutorials and examples and I guess i’m not missing anything.
Thanks for your time