codeAPI Reference
s&box TriggerTeleport: Trigger-based teleportation
TriggerTeleport Component API Reference
TriggerTeleport is a Component that teleports objects that enter its trigger collider to a target GameObject.
Type Signature
CSHARP
public sealed class TriggerTeleport : Component, Component.ITriggerListener
{
[Property, Group("Target")]
public TagSet Include { get; set; } = new();
[Property, Group("Target")]
public TagSet Exclude { get; set; } = new();
[Property] public GameObject Target { get; set; }
[Property] public Action<GameObject> OnTeleported { get; set; }
void ITriggerListener.OnTriggerEnter(Collider other);
bool IsValidTarget(ref GameObject go);
}Properties
Target Filtering
- TagSet Include { get; set; } - If not empty, the target must have one of these tags to be teleported.
- TagSet Exclude { get; set; } - If not empty, the target must not have one of these tags to be teleported.
Teleport Settings
- GameObject Target { get; set; } - The GameObject to teleport to. Must be valid.
- Action<GameObject> OnTeleported { get; set; } - Callback invoked after teleportation (broadcast via RPC).
Event Handlers
OnTriggerEnter(Collider other)
Teleports the object to the target position if it passes the tag filtering checks.Methods
IsValidTarget(ref GameObject go)
Checks if the GameObject is a valid teleport target:- Converts to Root GameObject
- Rejects proxy objects
- Rejects objects with Exclude tags
- Rejects objects without Include tags (if Include is not empty)
Usage
CSHARP
// Create a teleporter
var teleport = go.AddComponent<TriggerTeleport>();
teleport.Target = destinationGameObject;
// Only teleport players
teleport.Include = new TagSet { "player" };
// Don't teleport vehicles
teleport.Exclude = new TagSet { "vehicle" };
// Add a callback
teleport.OnTeleported = (obj) => Log.Info($"Teleported {obj.Name}");Notes
- Implements ITriggerListener to detect objects entering the trigger
- Uses TagSet for flexible filtering
- Teleported objects have their interpolation cleared to prevent snapping
- OnTeleported callback is broadcast via RPC to all clients
- Target GameObject must be valid for teleportation to work
Was this helpful?