3D Lingo Dictionary > O-S > setCollisionCallback()

 

setCollisionCallback()

Syntax

member(whichCastmember).model(whichModel).collision.setCollisionCallback (#handlerName, scriptInstance)

Description

3D collision command; registers the handler #handlerName in the given scriptInstance to be called when whichModel is involved in a collision.

This command works only if the model's collision.enabled property is TRUE. The default behavior is determined by the value of collision.resolve, you can override it using the collision.resolveA and/or the collision.resolveB commands. Do not use the updateStage command in the specified handler.

This command is a shorter alternative to using the registerScript command for collisions, but there is no difference in the overall result. This command can be considered to perform a small subset of the registerScript command functionality.

Example

This statement causes the #bounce handler in the cast member colScript to be called when the model named Sphere collides with another model.

member("3d world").model("Sphere").collision.setCollisionCallback\
(#bounce, member("colScript"))

See also

collisionData, collision (modifier), resolve, resolveA, resolveB, registerForEvent(), registerScript(), sendEvent