Teleport a target using Transform Setter
The Transform Setter component (Component) teleports the player, objects, or the main camera within your scene. It supports setting absolute positions and rotations, as well as relative offsets based on reference objects.
You can set up such teleportation by adding the Transform Setter component and configuring an Event Trigger to invoke the SetTransform, SetPosition, or SetRotation action.
Teleporting position and rotation simultaneously
-
Add an empty object from the Quick Create panel to your scene.
-
In the empty object's Properties window, add a trigger box and adjust its size to cover the desired activation area.
-
Click Add Component, search for the Transform Setter component under the Horror Logic package, and add it to the empty object.
-
Configure the Transform Setter based on your needs:
- Select the target to teleport: an object in the scene, the first-person player avatar, or the main camera.
- (Optional) Specify a reference object to provide position and/or rotation offsets.
- Enter the absolute or relative position coordinates as needed.
- Enter the absolute or relative rotation values as needed.
infoWhen the target references another object, its initial position and rotation are calculated based on its rotation at the time it is spawned.
For more details on the component, see Transform Setter.
-
Add an Event Trigger component to the empty object by clicking Add Event Trigger in the Properties window.
-
Configure the Event Trigger component:
- Set Trigger Object to Self (the empty object itself).
- Set Trigger Event to OnTriggerEnter (activated when an entity enters the trigger box).
- Set Action Object to Self.
- Set Action Function to SetTransform.
When the trigger box is activated, the specified target will be teleported to the configured position and rotation.
Example 1: Teleporting the player to an absolute position and rotation
Using the Horror playground template:
-
Add an empty object from the Quick Create panel and place it between the scene teleporter and the check point.
-
Add and size a trigger box on the empty object.
-
Add the Transform Setter component to the empty object.
-
Configure the Transform Setter:
-
Toggle on Set Local Player Avatar.
-
Set Position to (-9, 0.8, -0.05) behind a nearby desk.
-
Set Rotation to (0, 90, 0) so the player faces the spawn point after teleportation.
-
Leave other fields at default.
-
-
Add an Event Trigger component to the empty object.
-
Configure the Event Trigger component:
-
Set Trigger Object to Self (the empty object itself).
-
Set Trigger Event to OnTriggerEnter (triggered when entered).
-
Set Action Object to Self.
-
Set Action Function to SetTransform.
-
-
Enter Play Mode to test the player teleportation.
Example 2: Teleporting the player to a relative position and rotation
Using the Horror playground template:
-
Add an empty object from the Quick Create panel and place it between the scene teleporter and the check point.
-
Add and size a trigger box on the empty object.
-
Add the Transform Setter component to the empty object.
-
Configure the Transform Setter:
-
Toggle on Set Local Player Avatar.
-
Select a Wizard model nearby (Rotation: 0, 90, 0) as the reference object.
-
Set Position to (0, 0, 0) and keep Offset Position disabled.
-
Set Rotation to (0, 0, 0) and enable Offset Rotation.
-
-
Add an Event Trigger component to the empty object.
-
Configure the Event Trigger component:
-
Set Trigger Object to Self (the empty object itself).
-
Set Trigger Event to OnTriggerEnter (triggered when entered).
-
Set Action Object to Self.
-
Set Action Function to SetTransform.
-
-
Enter Play Mode to test the player teleportation.
Teleporting position or rotation separately
You can use the same setup to teleport only position or only rotation by adjusting the Action Function in the Event Trigger:
- To teleport position only, set Action Function to SetPosition.
- To teleport rotation only, set Action Function to SetRotation. Repeat steps 1–7 accordingly, leaving unused fields empty or disabled.