User Guide

Chapter 3142
Example
This example has three parts. The first part is the first line of code, which registers the
#putDetails handler for the #collideAny event. The second part is the #putDetails handler.
When two models in the cast member MyScene collide, the #putDetails handler is called and
the
collisionData argument is sent to it. This handler displays the four properties of the
collisionData object in the message window. The third part of the example shows the results
from the message window. The first two lines show that the model named GreenBall was model A
and the model named YellowBall was model B in the collision. The third line shows the point of
contact of the two models. The last line shows the direction of the collision.
member("MyScene").registerForEvent(#collideAny, #putDetails, 0)
on putDetails me, collisionData
put collisionData.modelA
put collisionData.modelB
put collisionData.pointOfContact
put collisionData.collisionNormal
end
-- model("GreenBall")
-- model("YellowBall")
-- vector( 24.800, 0.000, 0.000 )
-- vector( -1.000, 0.000, 0.000 )
See also
collisionData properties: modelA, modelB, pointOfContact, collisionNormal
collisionData methods: resolveA, resolveB, collision (modifier)
collisionNormal
Syntax
collisionData.collisionNormal
Description
3D collisionData property; a vector indicating the direction of the collision.
The collisionData object is sent as an argument with the #collideWith and #collideAny
events to the handler specified in the registerForEvent, registerScript, and
setCollisionCallback
commands.
The
#collideWith and #collideAny events are sent when a collision occurs between models to
which collision modifiers have been added. The
resolve property of the models’ modifiers must
be set to
TRUE.
This property can be tested but not set.