function beginContact(a, b, coll)
if a:getCategory()==2 and b:getCategory()==2 then
if a:getUserData() ~= b:getUserData() then
a:getBody():setActive(false)-- This produces the error
When I comment out the line of the error, I get no error. What might cause this?
BTW:
I'm not uploading a love file because my game is relatively big (with plenty of assets).
Boolsheet wrote:This is an uncaught exception. It's fixed in 0.9.0, I think.
You're not supposed to change the world during an update/timestep. To my knowledge, setting a body active or inactive counts as that.
So how would you suggest to make the bullet disappear and the enemy's body to change to dead?
I need some kind of flag, and the active property sounded good for that.
obey wrote:the active property sounded good for that.
Yeah, I wanted to use it like that too.
I guess you have to store the flag somewhere in a table. Haven't touched Box2D in quite a while and never did something big with it so I can't really go into the design of it, sorry..
obey wrote:the active property sounded good for that.
Yeah, I wanted to use it like that too.
I guess you have to store the flag somewhere in a table. Haven't touched Box2D in quite a while and never did something big with it so I can't really go into the design of it, sorry..
Yea I thought about creating a table, but how would I know which object to flag out? the collisions are referencing the fixture (you can't attach user data on it), so even that doesn't help.
I need a property that Is bound to the fixture/body/shape that I can change in order to flag it out.
function beginContact(a, b, coll)
if a:getCategory()==2 and b:getCategory()==2 then
if a:getUserData() ~= b:getUserData() then
inactive_bodies[#inactive_bodies + 1] = a:getBody()
function beginContact(a, b, coll)
if a:getCategory()==2 and b:getCategory()==2 then
if a:getUserData() ~= b:getUserData() then
inactive_bodies[#inactive_bodies + 1] = a:getBody()
function beginContact(a, b, coll)
if a:getCategory()==2 and b:getCategory()==2 then
if a:getGroupIndex() ~= b:getGroupIndex() then
a:setUserData("0")
b:setUserData("0")
end
end
end