question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detecting a collision

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RossNordbycommented, Oct 12, 2021

Thanks for trying it; looks like there’s a subsequent issue that b7566c2aa0bfa0ecb6b878bdf64e0a59dce86664 should help with.

0reactions
Valdiralitacommented, Nov 11, 2021

Thanks for trying it; looks like there’s a subsequent issue that b7566c2 should help with.

I’ve tested the latest master (a5049c6cb06797a9bb3dfad9a6cb86775cf3f91b) and the issue is fixed! 🎉 Can’t wait for the next release on nuget 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collision detection
Collision detection is the computational problem of detecting the intersection of two or more objects. Collision detection is a classic issue of ...
Read more >
2D collision detection - Game development - MDN Web Docs
One of the simpler forms of collision detection is between two rectangles that are axis aligned — meaning no rotation. The algorithm works...
Read more >
Collision Detection
Collision detection can be accomplished using code that ranges from simple if statements to complicated algorithms handling thousands of objects at once, ...
Read more >
Video Game Physics Tutorial Part II: Collision Detection
Continuous collision detection techniques attempt to find when two bodies collided between the previous and the current step of the simulation. They compute...
Read more >
detect-collisions
Detect -Collisions is a robust TypeScript library for detecting collisions among varied entities. It uses Bounding Volume Hierarchy (BVH) and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found