Assert in box2d (SOLVED)

Every once in a while, I get this assert:

Assertion failed: (bd->position.IsValid()), function b2Body, file …/src/box2d/Box2D/Dynamics/b2Body.cpp, line 27.

Haven’t been able to track it down to a specific event, other than it involves a certain game object containing kinematic collision type.

Interesting. It would be great if this could be isolated to a reproducible minimal example, or the steps to reproduce it could be clarified. Could you tell me a bit more about the setup? What kind of game is it? What kind of collision objects do you have? How many? And game objects, are they spawned and destroyed a lot?

@sicher: Do you recognise this? Anything else we need to know?

Not sure. Something here might ring a bell but that would be for something I saw ages ago. It would be great to get hold of a good isolated repro-case.

2 Likes

I will try to create an isolated case.

2 Likes

Were you able to isolate this or did you find a solution?

It’s on my to-do list. Will get there eventually.

1 Like

The position of the game object you are creating is not numerically valid (a number Box2D does not like to have in its calculations, essentially something that would destroy or destabilise the physics). Did you divide something with 0? Are you spawning that game object? If so, could you try printing the position of it before spawning? This should be handled more gracefully with a clearer error message.

You’re right, can see from the trace that we are passing nan values to set_position before an assert. Thanks!