B2d.body.set_active function and triggers

I have a player game object that contains three collision objects. Each one is for a specific state of the player object. So at any one time, only one is active

when the level starts I disable the two unwanted collision objects using (as an example)

local body = b2d.get_body(“#collision_crouch”)
b2d.body.set_active(body, false)

the problem is that when you do this within a trigger collision object it generates a “trigger response” with the “message.enter” value equalling false.

is this a bug or just a quirk of how the physic engine work?

Sounds a bit strange. What does the message contain in fields such as other_id and other_group? Are they nil?

they are both correct based upon the collision relationship between the two

i’ve attached a simplified project so you can see the problem

My Project.zip (359.3 KB)

when you crouch, the set_crouch function swaps over the collision object which generates an enter and then an exited message in the trigger object on the same frame

1 Like

I have managed to get around the issue by changing the collision type in these zones from “trigger” to “collision”. Their scripts have been adjusted so that they have a current and previous states variable. So if previous is false and current is true then the player has entered the zone.