I then planned to manage physical behavior on collision by getting the relevant information from the contact object passed through beginContact.
It probably doesn´t matter, but I am using windfield (for its nifty packaging the fixtures/bodies/shapes into one, I don't like its version of collision detection, so maybe I'll eventually write something that only does the former)
I wasn´t getting the behavior I expected, and when I checked it turned out that contact:getNormal was giving (7.19..., 0) , which is neither correct, nor a unit vector.
Code: Select all
function collide_bounce(obja, objb, coll)
local fa, fb = coll:getFixtures()
print(obja.fixture, fa)
print(objb.fixture, fb)
local nx, ny = coll:getNormal()
print(nx, ny)
...
end
Code: Select all
function beginContact(a, b, coll)
local obja = a:getUserData()
local objb = b:getUserData()
...
local i = collide_bounce(obja, objb, coll)
end
In this case the two Colliders are circles.
Also, potentially unrelated: after the circles pass through each other, they register a variety of collisions when they are not touching.
Any ideas what could be going on?