Collision Event

Description

The Collision Event behavior will trigger an event when two objects starts colliding, stop colliding or trigger continuously while colliding. When used with tags, you can check if your object has collided with multiple objects. If you don't specify an Object B to check for a collision, then this behavior will trigger when Object A touches anything in your scene.

This behavior will Trigger an event once when a collision happens. 

 

Collisions and Tags:

The Collided behavior is smart and will pass the tagged object to the next behavior that is using the same tag. This way you can trigger an action on a specific object with that tag instead of all tagged objects. For example, if you want to destroy a single enemy when using tags, make both the collided behavior and the destroy behavior use the same "enemy" tag.

If the tags for the two connected behaviors are not the same, then the action will happen to all objects in the scene with that tag.

 

Event Types

Started Colliding

Triggers Once on Event

Object A

By default this is the current object selected. You can change this to any other object in your scene.

Object B

Another object in your scene to check the collision against. If Object B is left blank then the behavior will trigger when Object A touches anything else in your scene.

World Coordinates

If toggled on, the behavior will output the position of the collision relative to either Object A or Object B.

On Top

When this toggle is on, an event will trigger when a collision occurs on the top surface of Object B.

On Bottom

When this toggle is on, an event will trigger when a collision occurs on the bottom surface of Object B.

On Left

When this toggle is on, an event will trigger when a collision occurs on the left surface of Object B.

On Right

When this toggle is on, an event will trigger when a collision occurs on the right surface of Object B.

 

While Colliding Stopped Colliding

Triggers Repeatedly on Event

Object A

By default this is the current object selected. You can change this to any other object in your scene.

Object B

Another object in your scene to check the collision against. If Object B is left blank then the behavior will trigger when Object A touches anything else in your scene.

World Coordinates

If toggled on, the behavior will output the position of the collision relative to either Object A or Object B.

Triggers Once on Event

Object A

By default this is the current object selected. You can change this to any other object in your scene.

Object B

Another object in your scene to check the collision against. If Object B is left blank then the behavior will trigger when Object A touches anything else in your scene.

Outputs

X

(Started Colliding, While Colliding)

This is the specific location where the collision happened relative to Object B or Object A along the X axis. If World Coordinates is enabled, this will output the horizontal position relative to the world.

Y

(Started Colliding, While Colliding)

This is the specific location where the collision happened relative to Object B or Object A along the Y axis. If World Coordinates is enabled, this will output the vertical position relative to the world.

Impulse

(Started Colliding)

This outputs the impulse of the force when Object A has collided with Object B.

Object A ID

This outputs the Object ID of Object A.

Object B ID

This outputs the Object ID of Object B

 

Examples

If you want a characters score to go up when it collects a coin. To do this, you would add a Collision Event behavior to your character, set the event type to be Started Colliding and then set the coin to be Object B. If there are many coins in your scene, then it probably makes more sense to tag the coins, and use the tag instead of the specific Object B. 

Download Example Project

 

Related

Create Collision 

 

CollidedReference.gif

0 Comments

Article is closed for comments.