Teleporting a NetworkTransform
I have player characters with NetworkTransforms that sync their Rigidbody2Ds. I also have a trigger that changes the scene and calls the following Respawn method on all player characters:
[ServerCallback]
public void Respawn(int id) {
Debug.Log("Respawn command!");
RpcTeleportToRespawn(id);
}
[ClientRpc]
void RpcTeleportToRespawn(int id) {
Debug.Log("Got it!");
foreach (GameObject spawner in GameObject.FindGameObjectsWithTag("Respawn")) {
if (spawner.GetComponent<PCSpawnMarker>().id == id) {
transform.position = spawner.transform.position;
Debug.Log("Teleported!");
}
}
}
This works fine for the (host's, who is the server) local player character, but for other connected players' (who have their own authority) characters just move to about the halfway point between their current position and the spawner's position. Is this because the NetworkTransform limits their movement somehow? How can I fix this?
Also, the debug messages all show up only for the server (but the server sees all players' debug messages), shouldn't the clients see their own debug messages from RpcTeleportToRespawn()?
I have got a similar problem right now and I would like to know if anyone managed to make it right?