objective: I have a player which instantiate by network manager class. I want to map/sync its position/rotation to another object which is also instantiate by my player object.
(what it i have tried) Below code is attached to my network player which instantiating another object (mimic object)
void Start() {
if (isLocalPlayer)
{
CmdInstantiate();
}
[Command]
void CmdInstantiate()
{
// This [Command] code is run on the server!
mimic = (GameObject)Instantiate(
mimicObject);
// spawn the bullet on the clients
NetworkServer.Spawn(mimic);
}
void Update()
{
if (!isLocalPlayer) {
return;
}
CmdMimicObjectPosSync();//updating position on server
}
[Command]
void CmdMimicObjectPosSync()
{//position sync method
mimic.transform.position = this.transform.position;
mimic.transform.GetChild(0).position = this.transform.GetChild(0).position;
mimic.transform.GetChild(1).position = this.transform.GetChild(1).position;
mimic.transform.GetChild(2).position = this.transform.GetChild(2).position;
}
it is working fine on the player side but another player who has joined the network unable to see it although mimic object has instantiated but its value remains same (no change). Mimic object has attached network identity and network transform.