Hallo,
I‘m working on a two parted player. It has a “Base” and a “Turret” like a Tank.
Actually the Base is spawned by the NetworkManager and everything is fine. It can be controlled by the correct client (Network Transform). The Turret is instantiate in the Start() Method of the base. So it’s normal that it won’t be synced.
I don’t know how to spawn the Turret.
I try this steps:
- give the Turret Network Identity and Transform
- put the Turret in the NetworkManager under Registered Spawnable Prefabs
- Idea A and Idea B
Idea A:
void Start () {
_model = Instantiate(TurretPrefab, transform.position, Quaternion.identity) as GameObject;
NetworkServer.Spawn(_model);
...
}
Problem A:
On the Host-Client the own Turret moves and rotates.
On the Client every Player got two Turrets and one of each Player moves and rotates.
Idea B:
I moved the Instantiate with a NetworkServer.Spawn in a Command like below
[Command]
private void CmdSpawnTurret()
{
_model = Instantiate(TurretPrefab, transform.position, Quaternion.identity) as GameObject;
NetworkServer.Spawn(_model);
}
Problem B:
On the Host-Client the own Turret moves and rotates.
On the Client no one got a Turret and the movement brokes completely.
How and where do I have to spawn the Turret?
Thanks for help