body:getContacts() returns contacts for bodies that are close but not touching.
A contact is returned when the distance between them is still roughly half their size.
I tried circleShapes and polygonShapes.
world:getContactList() seems to work correctly.
I created a minimal example to explain my question:
In the attached .love file press left/right arrowkeys to spawn balls that will move towards center of the screen.
Contacts are drawn as red squares:
Code: Select all
--draw contacts
lg.setColor(255,0,0,255)
local contacts = world:getContactList()
for i=1,#contacts do
local x1,y1,x2,y2 = contacts[i]:getPositions()
if (x1) then
lg.circle ("fill",x1,y1,6,4)
end
if (x2) then
lg.circle ("fill",x2,y2,6,4)
end
end
Code: Select all
local contacts = body:getContacts()
local x,y=body:getPosition()
lg.setColor (0,0,0,0.5)
lg.rectangle ("fill",x,y,10,10) --background for visibility
lg.setColor (1,1,1,1)
lg.print (#contacts, body:getPosition() )
Other balls show a number of contacts higher than zero but they are not touching.