3D Lingo Dictionary > O-S > pointOfContact |
![]() ![]() ![]() |
pointOfContact
Syntax
collisionData.pointOfContact
Description
3D collisionData
property; returns a vector describing the point of contact in a collision between two models.
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 MyScene collide, the #explode
handler is called and the collisionData
argument is sent to it. The first nine lines of the #explode
handler create the model resource named SparkSource and set its properties. This model resource is a single burst of particles. The tenth line of the handler creates a model named SparksModel using the model resource named SparkSource. The last line of the handler sets the position of SparksModel to the position where the collision occurred. The overall effect is a burst of sparks caused by a collision.
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.direction = vector(0, 0, 1) nmr.colorRange.start = rgb(0, 0, 255) nmr.colorRange.end = rgb(255, 0, 0) nmr.lifetime = 5000 nm = member("MyScene").newModel("SparksModel", nmr) nm.transform.position = collisionData.pointOfContact end
See also
![]() ![]() ![]() |