Teleport a player to a location
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Teleport a player to a location
nnnnnzo
2020-06-13 15:41:52
Hi, anybody know how to teleport the local player to a Vector 3 location from an UI (more precisely: a button) ?
I use the usual
MyPlayer.position = new Vector3(59.611f, 25.67776f, 317.791f);
with
public Transform MyPlayer;
inside a "void TP1()" function but it do not seem to do the trick with PUN
Thanks
Comments
DarkJoltGames
2020-06-22 21:14:37
Hello! First off, make sure your player's transform is connected to the transform MyPlayer:
transform.position = MyPlayer.position;
Then, simply change your void TP1 function to:
[PunRPC]
void TP1(){
MyPlayer.position = new Vector3(59.611f, 25.67776f, 317.791f);
}
And call the function like so:
gameObject.GetComponent
This will call the function on everyone's client. Cheers!
Thank's it work well ! Have a good day !
Back to top