The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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().RPC("TP1", PhotonTargets.All);

This will call the function on everyone's client. Cheers!

nnnnnzo
2020-06-24 11:45:35

Thank's it work well ! Have a good day !

Back to top