I am trying to spawn/teleport players looking in a certain direction (for example, north). I have tried setting:
player.ServerRotation = Quaternion.Euler(0f, 0f, 0f);
player.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
player.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
player.transform.SetPositionAndRotation(new Vector3(0, 0, 0), Quaternion.Euler(0f, 0f, 0f));and calling
player.TransformChanged();afterwards, however it has no effect.
So I did some more debugging with a chat command to see what the current rotation is according to the server:
SendReply(player, $"{player.ServerRotation.eulerAngles}");
SendReply(player, $"{player.transform.localRotation.eulerAngles}");
SendReply(player, $"{player.transform.rotation.eulerAngles}");All I get are 0.0,0.0,0.0 for all of them, and 0.0,0.0,0.0,1.0 if I remove the .eulerAngles, no matter which way my character is facing.
"printrot" in the console works fine locally.
I also tried setting it on a player when they respawn, which also did not work. The position did, but the rotation did not.
object OnPlayerRespawn(BasePlayer player)
{
var sp = new BasePlayer.SpawnPoint();
sp.pos = new Vector3(0, 0, 0);
sp.rot = Quaternion.Euler(0f, 0f, 0f);
return sp;
}
Anyone know what I'm doing wrong here?
Thanks!