Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.32

Description

Description:Adds an event handler to an object, which fires when the specified selection collides with something.

Syntax

Syntax:object addCollisionEventHandler [component, code, repeat]
Parameters:
  • object: Object - Object to receive the event handler.
  • component: String - Selection name (must exist in the Geometry LOD, and must not be in the notation "Component ##")
  • code: String - Code that should be executed, when the event occurs. The code is passed data in the _this variable, which contains: [object with event handler, component name, object it collided with, collision enter / exit]
  • repeat: Boolean - Repeats the event call during the duration of the collision.
    • If repeat is set to true, then the supplied code is executed each frame, while there is a collision with the component. When the collision with a component ends, the code is called with parameter 4 set to false, to indicate there is no longer any more collision with the component, and parameter 3 is null.
    • If repeat is set to false, then the code is only executed upon entering the collision, and on exiting the collision. This is the recommend method of using addCollisionEventHandler for a component, considering that the script does not need to constantly monitor the collision between two objects. When a collision occurs for the first time, parameter 4 passed to the _this array is set to true, to indicate collision entrance. When the collisions stops, parameter 4 passed to _this is false, and parameter 3 is Variables - Null, to indicate there is no longer a collision with the component.
Return Value:Number - Event handler index (to be used with removeCollisionEventHandler)

Examples

Examples:
car1 addCollisionEventHandler ["trunk",{hint "trunk was hit"}]

Additional Information

See also: removeCollisionEventHandler, addEventHandler
Multiplayer: 
Problems: 

Notes