userTrigger

The userTrigger responds to a user entering or leaving a space. userTriggers can be spherical or box-shaped, and are usually invisible. You can use the userTrigger to make a light turn on when you walk into a room, make a sound play when you walk out of it, or tell an object to start animating when you walk near it.


A user, a userTrigger, and a light.


When the user enters the radius around the trigger,
it sends a message to the light.

// userTrigger.scene // turns on a light when you walk near the trigger #include "User0" // put in a floor object (file(floor.b3d)) // initial light color is a dim yellow light light1 (diffuse (.2 .2 0)) // create a userTrigger node userTrigger (volume (sphere 0 20 0 10), when(enter,light1.diffuse(1 1 0)))

Node Reference

Derived from: ygSpace

Messages

MessageParametersDefaultDescription
volume string volumeShape, float coordinates ...

sphere x y z radius
box x1 y1 z1 x2 y2 z2
cylinder x1 y1 z1 x2 y2 z2 radius
point x y z
infinite
infinite defines the shape of the trigger's active area. the volumeShape can be one of the following:
  • infinite: the trigger is active throughout the world
  • sphere: x y z is the location of the trigger; radius is the radius of the sphere.
  • box: x1 y1 z1 and x2 y2 z2 define two opposite corners of a box
  • cylinder: x1 y1 z1 and x2 y2 z2 are centers of the ends of the cylinder; radius is the radius of the cylinder.
  • point: x y z is the location of the trigger.

Events

EventVariablesDescription
enter$usera user has entered the space
exit$usera user has left the space
firstenter$usera user has entered the space
empty all users have left the space

(c) Ben Chang