Teleport Portals
See the chapter on Triggers and Interactivity
for more information about coding and using trigger nodes
The teleport function is usually used to create 'portals' or 'warps' - places in your world that transport you to another location. To do this, the teleport message is not actually put in the user file, but rather in an event from a trigger. The enter event for the trigger node will send a teleport message over to the user node. It can do this even though the user node is in a different file, because the #include command makes them all part of the scene scene.
For this example, there are two files: the main scene file, and the user file. walking into the door at the end of the hallway brings you back to the beginning again.
// scenes/infinitehallway.scene
#include "User0.scene"
light (position(0 0 10 1))
object (file("hallway.b3d"))
userTrigger (volume(box -5 20 0 5 25 10),when(enter,User0.teleport(0 0 0)))
// users/User0.scene
user User0 ()
{
caveNavigator navigatorUser0 ()
caveHead headUser0 ()
caveTracker wandTrackerUser0 (sensor(1))
{
caveWand wandUser0 ()
{
}
}
}
Teleporting Any User
You may want to set up the portal to teleport ANY user who walks into it - this way you can use different user files with the same scene without recoding the trigger, and you can also have networked scenes with multiple users. The UserTrigger node has a variable called $user that tells you which user entered the trigger; you can use this variable with the teleport message instead of specifying the user node explicitly.
// scenes/infinitehallway.scene
#include "User0.scene"
light (position(0 0 10 1))
object (file("hallway.b3d"))
userTrigger (volume(box -5 20 0 5 25 10),when(enter,$user.teleport(0 0 0)))
(c) Ben Chang