contact_point_response can be sent multiple times per frame while collision_response happens once per frame.
Mentioned in this thread: Physics Contact Response (SOLVED) - #2 by britzl
Without knowing for sure what a frame entails in this scenario, I am currently confused by this.
My scenario is that a bullet hits an enemy.
The enemy listens on collision_response
and in the handler I ask my playerbulletmanager
(lua module) to get the data tied to that bullet instance.
The bullet is ‘consumed’ and thus deleted by go.delete
, all inside this message handling function.
Immediately after this message, there’s another identical message. Possibly because I have some overlappping shapes in my collision object? Not sure if that brings this effect.
Now, I handle this by first checking if my playerbulletmanager
still “has” this bullet (it does not, it’s deleted since last message). This works fine, but I want to know if this is correct behavior.
I’d like to do something like this in my manager:
function M.get_bullet(instance)
assert(bullets[instance] ~= nil, "Bullet does not exist: " .. tostring(instance))
return bullets[instance]
end
It’s just nice to have, to help me ensure I don’t do unexpected things.
But this throws tons of errors now due to multiple collision_response
messages, since the bullet is already gone!
But I don’t really want to ask for that bullet more than a single time. And it feels convoluted that my enemy should also keep a table on which bullet instances it has already consumed and not ask for again.