User Guide

394 Chapter 17: Controlling the 3D World
Use these methods to set up event handling:
Collisions
By attaching the collision modifier (#collision) to a model, you can enable that model to
automatically respond to collisions with other models. By using the properties of the collision
modifier, you can control the details of how the model responds to collisions. For more
information about collisions, see “Modifiers” on page 366.
Collision properties
When a collision occurs, it generates a
collideAny event or a collideWith event.The
collideWith event passes an argument to the handler that is declared with the
registerForEvent, registerScript, or setCollisionCallBack method. This argument is
called a
collisionData object and contains a property list with detailed information about
the collision.
Method Description Returns
registerForEvent
(eventName,
handlerName,
scriptInstance,
model)
The event eventName is one of the following:
#collideAny: Called when any collision occurs.
#collideWith: Called when a collision with a specific
model occurs and implicitly registered when
setCollisionCallback(...) is called. Equivalent to
calling
model.collision.setCollision
Callback
.
#timeMS: Sets up a time-based simulation callback
using the format
registerForEvent
(timeMS, handlerName, scriptInstance)
begin, period, repetitions
.
The
begin and period arguments are in
milliseconds. If
repetitions is set to 0, the simulation
continues indefinitely.
#animationStarted: Called whenever a keyFrame or
bones motion begins.
#animationEnded: Called whenever a keyFrame or
bones motion ends.
Any user-defined symbol: Registers to receive any
user-defined event sent from a SendEvent call.
TRUE (1) if the
operation succeeds.
FALSE (0) if the
operation fails.
unregister
AllEvents()_
Unregisters all events. Nothing.
A script error is
generated if the
operation fails.
sendEvent
(eventName,
arg1,arg2...)
Sends an event named eventName to all scripts
registered to receive it.
Similar to
sendAllSprites() except that the event is
delivered only to scripts that are registered to receive
it.
Nothing.
A script error is
generated if the
operation fails.