Detecting a collision
See original GitHub issueI’m trying to create a kinematic entity (A) that can detect when another entity (B) is inside or intersecting with it. Like a trigger or sensor object, it doesn’t interact with the other (dynamic or kinematic) entity B, that should be detected, in any way.
So I use the ConfigureContactManifold callback to see if there is a collision. Just assuming that we have a collision inside that function yields collisions for objects that dont collide. I’ve tried to add a check wether they really collide:
var hasNonNegativeContact = false;
for (var i = 0; i < manifold.Count; i++)
{
if (manifold.GetDepth(ref manifold, i) >= 0)
{
hasNonNegativeContact = true;
break;
}
}
if(hasNonNegativeContact)
{
// we have collided
}
That works for simple stuff, but if the entity B uses a mesh collider that check doesn’t work.
I made two observations:
1:
Sometimes there are more than 4 contacts and the contacts are “cleaned up” inside of unsafe void ChooseMostDistinct(NonconvexContactManifold* manifold, BufferPool pool)
which reduces it to 4 contacts.
In some cases it chooses the “wrong” contacts and only contacts with negative depth remain.
2: manifold.Count is 0 (Demo)
What would you recommend for filtering out non colliding entities?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks for trying it; looks like there’s a subsequent issue that b7566c2aa0bfa0ecb6b878bdf64e0a59dce86664 should help with.
I’ve tested the latest master (a5049c6cb06797a9bb3dfad9a6cb86775cf3f91b) and the issue is fixed! 🎉 Can’t wait for the next release on nuget 😉