Are you trying to remove the physics body on collision? If so you should probably set a timer that triggers when a collision occurs and removes the body when its complete.
Yeah, you can't manipulate objects in Box2D from a collision handler. The solution is to wait a frame (until the next step) and then do it (like dreiko65 said).
As others said, you can't modify/update the world from within a collision callback, because technically the callback is already called from a world update. You have to defer your world changes until next frame.
Can your share the code that you use so that we can help you further ?
I'm not sure if collisions exist between static objects. Static objects are not meant to move so it's hard to see how they would collide unless you create them directly on top of each other. If you want objects you move yourself, you should create kinematic objects. Finally if you want objects to move around according to forces like gravity, use dynamic objects.
So what are you trying to achieve with static objects?
@john26 They are static, Box2D speaking, but they move accordingly to some custom physics I made changing their position/rotation each frame. And when I mean colliding I basically mean touching (because I use Box2D just for its precision to detect collision between rotated objects) I figured the problem out though. Thank you for all the help and support!
Comments
Likes: antix
As others said, you can't modify/update the world from within a collision callback, because technically the callback is already called from a world update. You have to defer your world changes until next frame.
Can your share the code that you use so that we can help you further ?
So what are you trying to achieve with static objects?
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
They are static, Box2D speaking, but they move accordingly to some custom physics I made changing their position/rotation each frame. And when I mean colliding I basically mean touching (because I use Box2D just for its precision to detect collision between rotated objects)
I figured the problem out though. Thank you for all the help and support!
Only dynamic collide with all types (dynamic, static, kinetic)
Likes: antix, totebo
Likes: ar2rsawseen