why dont working?Code:void OnPlayerRespawn(PlayerSession session) { Teleport(session,new Vector3(187,177,990)); hurt.SendChatMessage(session,session.Name+":Respawn!"); }void Teleport(PlayerSession player, Vector3 location) { hurt.SendChatMessage(player,"Teleport"); GameObject playerEntity = player.WorldPlayerEntity; playerEntity.transform.position = location; }
help me How can Working?
Can't get teleport working
Discussion in 'Hurtworld Development' started by 不是很会玩, Mar 17, 2016.
-
Firstly, the Respawn isn't the best place to transform location, as it will teleport the player anyway, so unless you add a delay it's not going to work.
As for your transform. There's no need to get the GameObject of a GameObject. Use WorldPlayerEntity from the PlayerSession (Thats the player gameObject) to make things simple.
Example:
Code:void Teleport(PlayerSession player, Vector3 location) { hurt.SendChatMessage(player,"Teleport"); player.WorldPlayerEntity.transform.position = location; }
A much easier way to do this, which I recommend. Is to just use the hook OnFindSpawnPoint and return the Vector3.
Code:object OnFindSpawnPoint() { return new Vector3(187f, 177f, 990f); }
Last edited by a moderator: Mar 17, 2016 -