I’m trying to figure out a concrete way to calculate multiple collision events which happen within a single frame. Is there some defined order to how messages are received and the update loop is processed, or should I assume the order is more or less random? If the latter, does anyone recommend a good system for managing multiple collision events which happen close to one another? The reason I’m asking is I’m trying to determine if my player is being crushed by a moving object against the level terrain.
I’m pretty sure that gos collide in the same order they render in (higher z layer in the rendering means it collides first). If possible, I would recommend to store the gos’ ids in a table, and process them individually when collide is called. What collision types do you use for your player, terrain, and moving object?
Thanks, I figured it out. I now set a collision state to false during my update loop and true during the collision processing. If there was another normal generated and the collision processing is the mover element I am able to compute if it’s crushing me using the dot product. This gives good results for me.
The physics engines have their own internal representation, that is spatially divided in either 2d or 3d. The 2D engines typically don’t have any notion of a Z dimension or “layers”. Box2D doesn’t have that.
After the collisions are registered, we callback to Lua to the on_message()
function.