Humanoid Control comes with built-in teleport support which can be customized using standard Unity solutions. The Teleporter is a specific implementation of an Interaction Pointer.
Two types of teleportation are supported:
- Gaze based teleportation
- Hand pointing based teleportation
You can enable gaze based teleportation on the Head Target of the Humanoid. Here you will find an ‘Add Teleporter’ button:
When this button is pressed, a Teleporter GameObject (see below) will be attached to the Head Target. It will be active by default so that you will see the focus point continuously when running the scene.
The focus object is a simple sphere, while no line renderer is present.
Additionally, the Left Button One of the controller will be set to the Click event of the Teleport which will teleport the humanoid to the location in focus:
The Left Button One will match the Menu Button on the SteamVR Controller and the X button of the Left Oculus Touch Controller.
Hand pointing based teleportation is activated on either Hand Target. Like above, you will find an ‘Add Teleporter’ button here:
This will add a Teleporter GameObject to the Hand Target. In this case, no focus object is used, but an line renderer is used to show the pointing direction. This is visible as a standard pink ray on the hand.
Pointing teleporting is activated when the ‘One’ button is pressed. While the Click event is matched to the Trigger button. The former matches to the Menu Button on the SteamVR controller which the latter is the Trigger on this controller. On the Oculus Touch, the One button is the X or A button, while the trigger button is the Index Finger Trigger button.
Of course you can change these button assignments through the editing of the Controller Input, setting the desired button to the Teleporter.Activation and -.Click functions.
|Active||Activates and shows the Target Point Object. It will update the Object’s Transform and Line Renderer if available.|
|Timed Teleport||Automatically teleports after the set amount of seconds. The value 0 disables this function.|
|Target Point Object||This is the GameObject which represents the target for the teleportation when it is active.|
|Mode||The ray mode for the pointer. You can choose between a straight line, a bezier curve and a gravity based curve.|
|Transport Type||Determines how the Transform is moved to the Target Point. Teleport = direct placement to the target point. Dash = a quick movement is a short time from the originating point to the target point.|
For more information on these parameters, see the Interaction Pointer.
Target Point Object
The target point object is disabled or enabled automatically when the Teleporter is activates or deactivated.
The Transform of the target point object will be updated based on the ray curve to match the location where the teleport will go. It will be aligned with the Normal of the surface.
This object can be used to show the target of the teleportation in the way you like.
When an line renderer is attached to the Target Point Object, it will automatically be updated to show the line ray casting curve. You can change this line render to your likings. Only the positions will be overwritten when the teleporter is active.