Build a teleport pad
Short version
Create a script from the teleport pad example. Build a prefab level: pad
(model), trigger (box_trigger + your script, with a burst_fx effect child) and arrival (with its own
burst_fx). Place it twice as tp_a and tp_b, patch each trigger’s destination_entity_name to the other, save,
run.
Step on one pad, arrive at the other. This tutorial builds the pads in Studio; the script itself is explained line by line in the teleport pad example.
1. Add the script
Section titled “1. Add the script”- In a folder of your own, Assets▸Create… CtrlN › Script, starting from a plain component. Name it
teleport_pad. - Replace its contents with the script from the teleport pad example.
- CtrlS.
No underlines and nothing in Problems from your changes. The script is compiled, so it can now be added to an entity as a component.
2. Build one pad
Section titled “2. Build one pad”Make a new level to hold one pad: Assets▸Create… CtrlN › Prefab level, named teleport_pad. Open it
and build this tree with the Entity menu and Add component:
- teleport_pad
- padtransformmodelany flat model, so players can see it
- triggertransformbox_triggerteleport_padyour script
- burst_fxtransformeffectplay_on_created off, kill_on_done on
- arrivaltransformwhere players sent here land
- burst_fxtransformeffectthe same settings
- Size the trigger by scaling its entity to cover the pad, with View▸Volumes▸Triggers ShiftT on to see it. A trigger’s box size is half its width, so the default box and a scale are the easiest route. See Collision and triggers.
- Move arrival a little in front of the pad and above the ground.
- Pick any effect for the two
burst_fx. Turnplay_on_createdoff andkill_on_doneon, so they wait to be told and clean up after themselves.
Save.
3. Place it twice
Section titled “3. Place it twice”Open the hideout and drag your teleport_pad level from the Project window onto the roof twice, well apart. Rename
the two placements tp_a and tp_b (Edit▸Rename… F2).
Two pads on the roof. In the Outliner each placement has the pad’s entities under it, in italics: they come from the prefab.
4. Point them at each other
Section titled “4. Point them at each other”Each placement needs to know where to send people, which takes a patch: a value one placement changes without touching the prefab.
- Under
tp_a, select its trigger and setdestination_entity_nameon itsteleport_padcomponent totp_b. - Under
tp_b, set it totp_a.
A dot appears on each patched field, and the change is saved on the placement, not in the prefab. Save the hideout.
5. Test
Section titled “5. Test”Press Run and walk onto a pad in the hideout.
You arrive at the other pad, with a burst at both ends. A loose ball rolled onto a pad travels too; one someone is holding stays in their hands.
What just happened
Section titled “What just happened”You made three new files (a script, a prefab level, and your copy of the hideout) and used a prefab the way the game does: one file, two placements, each patched to be a little different. Add a third pad pair anywhere in the hideout by placing the prefab twice more and patching the names.
Where to go next
Section titled “Where to go next”- The teleport pad example, for how the script works.
- Server and client, for why it runs on every machine.