How to Teleport a Player - Udon / VRChat SDK3.0

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Ok, I would like to make a button, that  when clicked, teleports the player. Here’s how I would go about doing that. To do so, we need two things. A button, and a location to teleport to. First let’s start with the button: To make the button, I’m going to go into the  hierarchy and right-click, 3d object, cube. I’m going to call it teleport button,   and then come down to the transform  and set its scale down to 0.1, 0.1, 0.1 Then I’m going to fly around and go  ctrl- shift- f to place it where I am;   and then I’m going to reset some of its rotation. Now, as this is a button and I don’t  want players to collide with it,   I’m going to come down to the box collider  and hit ‘isTrigger’ and make that true. I’m then going to come down to  add component, udon behaviour. Now we need a script to go inside  this udon behaviour component,   so I’m going to come into my project window. Right-click and go create, VRChat,  udon, udon graph program asset;   and I’m going to call it teleport button. And then I’m going to open up the udon graph. Now that we are in the udon graph, I’m  going to come over to my variables tab   and hit this little plus button and  we are going to create a transform. I’m going to call this targetLocation,  and then I’m going to hit this little   dropdown and make it public so we  can select it inside the inspector. I’m then going to come into the  graph and right-click, create node   (the shortcut for this is spacebar),  and then go player api, teleport to This node requires three things inputs. a player to teleport, and the position  and rotation we want them to have,   represented as a vector3  and quaternion respectively Now, the player we want to teleport is the local  player, so I’m going to go create node,   networking, get local player, and  plug that into the instance slot. Now we want the location where we want the  player to teleport to, so I’m gonna grab my transform, and drag that into the graph, and then put that transform into a 'transform, get position' node. And now we have a vector3 to plug  into the teleport position slot. We also want to create a  transform, get rotation node;   and plug the resulting quaternion  into the teleport rotation slot. Awesome! So now whenever we call this node, it  will grab the local player, and teleport it to the   position of our public transform; and it will also  rotate the player to be the same as that as well. Now we just need to say when  we want this node to be called. I’m just going to create an event, interact node. And plug it into the arrow  slot of the teleport to node. So now, whenever we click the  button, it will play this node. Awesome! Now coming back into our scene view. we now need to create an object,  that will be our teleport location. I’m going to come into the hierarchy  and right-click, create empty. I’m going to call this teleport location. I’m then going to fly over to where I want   the player to be teleported to, go  ctrl-shift-f to place it where I am. And then tweak its rotation Now coming back to our button,   I want drag and drop our new script  into the udon behaviour component. I’m going to change its interaction text to  be ‘teleport’, and come up to our hierarchy,   and drag and drop our empty gameObject and  plug that into the target location variable. And now, it’s time to test this. Now that we are in the world,  when we can click our button,   we should see our player  teleport to the new location. Awesome! So now, what if we wanted it to teleport everyone. Well, to do that, we need to  come back into our udon graph. I’m going to go, create node, custom event. I’m going to call it Teleport Players; and then  I’m going to plug that into the teleport to node. I’m then going to drag our event interact node up,  and instead of it going into the teleport to node,   I’m going to plug it into an udon  behaviour, send custom networked event. I’m going to make sure it’s target  is set to all, and on the event name,   I’m going to click on this dropdown menu, and  select the custom event that we just made. Awesome, so now when we hit this button, it  will tell everyone to play this custom event. That in turn will make everyone play this  node, teleporting them to the new location. Now we just want to hit compile, and come  into the VRChat SDK and build and test,   running two instances so we  can test out the networking. Now that we are in the world, we  can see that when I hit the button,   everyone gets teleported to the new location. So now, teleporting the player can  be super useful if you are making a   game world with multiple levels, or even just  creating a lobby while the game is playing. Then again, you could just change the  script to work with a pickup instead,   attach that to an object synced wand, to leave you  with a wand that can summon everyone in the world. There’s no way that will end badly… Anyways, hopefully you found this helpful Feel free to leave a like on the video if you  liked it, leave a comment down below if you have   any questions, and feel free to check out some  of my other tutorials that I have on the channel. But until next time, BYE!
Info
Channel: PlayerBush001
Views: 27,831
Rating: undefined out of 5
Keywords: VRChat, SDK3, Udon, Worlds
Id: ZcwdAgZywDQ
Channel Id: undefined
Length: 4min 2sec (242 seconds)
Published: Sun Feb 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.