3D Lingo Dictionary > C-D > collisionNormal |
![]() ![]() ![]() |
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.
Example
This example has two parts. The first part is the first line of code, which registers the #explode
handler for the #collideAny
event. The second part is the #explode
handler. When two models in the cast member named MyScene collide, the #explode
handler is called and the collisionData
argument is sent to it. The first ten lines of the #explode
handler create the model resource SparkSource and set its properties. This model resource is a single burst of particles. The tenth line sets the direction of the burst to collisionNormal
, which is the direction of the collision. The eleventh line of the handler creates a model called SparksModel using the model resource SparkSource. The last line of the handler sets the position of SparksModel to the position where the collision occurred. The overall effect is a collision that causes a burst of sparks to fly in the direction of the collision from the point of contact.
member("MyScene").registerForEvent(#collideAny, #explode, 0) on explode me, collisionData nmr = member("MyScene").newModelResource("SparkSource", #particle) nmr.emitter.mode = #burst nmr.emitter.loop = 0 nmr.emitter.minSpeed = 30 nmr.emitter.maxSpeed = 50 nmr.emitter.angle = 45 nmr.colorRange.start = rgb(0, 0, 255) nmr.colorRange.end = rgb(255, 0, 0) nmr.lifetime = 5000 nmr.emitter.direction = collisionData.collisionNormal nm = member("MyScene").newModel("SparksModel", nmr) nm.transform.position = collisionData.pointOfContact end
See also
pointOfContact
, modelA
, modelB
, resolveA
, resolveB
, collision (modifier)
![]() ![]() ![]() |