Is there a way to determine which normal you came out of from a trigger collision?

As the title states:
Is there a way to determine which normal you came out of from a trigger collision?

Basically if I’m leaving the EAST side of a cube, how can I determine that? Or is there another way of thinking of this.

The event fired when leaving a trigger volume (triggerleave) returns the entity only that exits the volume:

https://developer.playcanvas.com/en/api/pc.CollisionComponent.html#event:triggerleave

So to do that you will have to code some basic maths:

  • Get the position of the trigger volume
  • Get the position of the entity leaving the volume
  • Find the angle between the two points to understand the direction the object is leaving from.

Helpful thread on how to find the angle given two vectors (your positions):

1 Like