Object Teleportation

There are many ways to teleport an object using Unity and the SDK. This guide will go over the different methods as well as the pros and cons of each method. The default SDK option is TeleportTo. Since TeleportTo is full of bugs, we found many other ways to teleport objects. Some methods are more advanced than others.

Note: For all of these teleports, you need to make sure that the owner of the object is told to teleport the object. (See VRC_ObjectSync to learn about ownership.) If you try to move a synced object you do not own, the object's position will be overwritten by the position the object owner sees, therefore only the owner can move an object and leave it there. If the object is not synced, then you don't need to worry, as you are the owner. In this case though, you should make sure to keep broadcasts to local. See Broadcast Types to learn more about the different broadcast types.

Similarly, it is a good practice to use Drop on a pickup before you attempt to teleport it. Some teleportation methods may fail or behave strangely if a pickup is held by a player while teleporting.


TeleportTo

The Easy SDK Trigger That's Too Buggy to Use

The simplest way to teleport an object is to use the built in VRC_Trigger's TeleportTo. This only works on objects with VRC_ObjectSync and can be found in Events From Scene instead of Basic Events. While this teleport can work, it is also full of bugs and I personally (CyanLaser) cannot recommend using this trigger action. Some of the known bugs that may occur when using TeleportTo:

FollowTarget

An Easy to Set Up Script that Follows a Target

The simplest form of teleport for an object that is not directly from the SDK is FollowTarget. FollowTarget is a script included in Standard Assets. Every frame it will force the object's world position to be the same as the target object's position, plus the offset. We can use this as a way to teleport one object to another object. The main limitations with FollowTarget teleportation is that you can only teleport it to one location and it completely ignores rotation. The one location can be changed to multiple locations if you move the target, but I will not go over that here.

FollowTarget teleportation using Triggers

  1. Import Standard Assets either from Assets/Import Package/Cameras or the entire package from the Asset Store.
  2. On the object you want to teleport, add the FollowTarget script.
  3. Set the offset to be (0, 0, 0)
  4. Set the target to be an object positioned where you want this object to teleport to. Note: You can use any object for this, including moving objects.
  5. Turn the FollowTarget script off.
  6. Add a VRC_Trigger script to this object
  7. Add a custom trigger and name it "Teleport"
  8. Add a SetComponentActive to this custom trigger, drag itself into the receiver, select FollowTarget from the drop down, set it to True
  9. Add another custom trigger to this GameObject and name it "TeleportDisable". Set the broadcast type to local, and add a delay of 0.01.
  10. Add a SetComponentActive, drag itself into the receiver, select FollowTarget from the drop down, set it to False
  11. In the "Teleport" custom trigger, add an ActivateCustomTrigger, drag the GameObject into the receiver, and select "DisableTeleport"
  12. Call "Teleport" to teleport the object

Relevant Images:

The broadcast for the "Teleport" custom trigger depends on your situation. If it is a non-synced object, or you are guaranteed to be the owner when it is called, use "Local". If you do not know who the object owner is, use AlwaysUnbuffered. If this is being called from a synced animation or another broadcast trigger, I recommend using MasterUnbuffered to ensure everyone doesn't broadcast to everyone to do the teleportation.

AutoCam

A More Powerful Follow Script

Similar to FollowTarget is a script called AutoCam. This script is the more powerful version of FollowTarget as it allows for position, rotation, and changing the speed of following. It is possible to set the speed to a high number to appear as a teleport, or you can use it with slower values to have it smoothly follow the target object. AutoCam also provides a function for changing the target. This cannot be called with triggers, but can be called with UI buttons.

AutoCam teleportation using Triggers

  1. Import Standard Assets either from Assets/Import Package/Utilities or the entire package from the Asset Store.
  2. On the object you want to teleport, add a camera component and then disable the camera component. This is only here so the script doesn't throw an error. It will not be used otherwise.
  3. On the same object, add the AutoCam script.
  4. Set the target to be an object positioned where you want this object to teleport to. Note: You can use any object for this, including moving objects.
  5. Uncheck the Auto Target Player checkbox.
  6. Set the Update Type to "Late Update"
  7. Set Move Speed, Turn Speed, and Roll Speed to "Infinity". "Infinity" is a keyword used for the max float value.
  8. Set Spin Turn Limit, Target Velocity Lower Limit, and Smooth Turn Time to 0.
  9. Turn the AutoCam script off.
  10. Add a VRC_Trigger script to this object
  11. Add a custom trigger and name it "Teleport"
  12. Add a SetComponentActive to this custom trigger, drag itself into the receiver, select AutoCam from the drop down, set it to True
  13. Add another custom trigger to this GameObject and name it "TeleportDisable". Set the broadcast type to local, and add a delay of 0.01.
  14. Add a SetComponentActive, drag itself into the receiver, select AutoCam from the drop down, set it to False
  15. In the "Teleport" custom trigger, add an ActivateCustomTrigger, drag the GameObject into the receiver, and select "DisableTeleport"
  16. Call "Teleport" to teleport the object

The broadcast for the "Teleport" custom trigger depends on your situation. If it is a non synced object or you are guaranteed to be the owner when it is called, use "Local". If you do not know who the object owner is, use AlwaysUnbuffered. If this is being called from a synced animation or another broadcast trigger, I recommend using MasterUnbuffered to ensure everyone doesn't broadcast to everyone to do the teleportation.

Relevant Images:

AutoCam teleportation using UI Buttons

  1. Follow steps 1-8 above.
  2. Change the Update Type from "Late Update" to "Manual Update".
  3. Create a new GameObject and name it "Teleport". Disable this object.
  4. Add a UI Button component.
  5. Add three events to the button. The first two should both call AutoCam.ManualUpdate(). The last to turn off itself.
  6. Add the animation EventSelectorOnce to the object
  7. Enable the "Teleport" GameObject to teleport your object.
  8. Using another UI Button, call SetTarget(object) to change the teleport location.

Relevant Images:

Animation

This One Weird Trick Will Move Your Object

Coming soon
CyanLaser's video tutorial on using legacy animations to teleport objects. Note the end section of tutorial is slightly out of date.

VRC_SceneResetPosition

Coming soon
Requires a UI Button to call VRC_SceneResetPosition.ResetPosition().

Relevant Images: