I am currently developing a 2D racing game and have run into a bit of a problem.
I have a start line defined as an edgecollider2D trigger, the cars are rigidbody2D (set to interpolate) with a simple circle collider set to continuous collision.
I am finding that the startline triggers can be missed (they do tend to be on the fastest/longest straights so the cars are travelling the fastest crossing these). I assumed the continuous collision on the cars would always detect these but it seems this is not the case, is this a known issue?
I am not particularly familiar with 2D in Unity, reading the docs it does seem to suggest that maybe a static colider with no rigidbody is not handled with the continuous method. Is this correct?
I have solved the problem by triggering laps using an analysis of the track spline/car spline point rather than relying on a trigger but am a bit concerned about track edge collisions as these are also defined with edgecollider2Ds. I have not seen an issue with the track edges though, maybe because they are static NON triggers perhaps and handled differently…?
Not sure if this applies to your case, but if a game object moves very fast and the shape of your collider is very small it can miss the collider. In one frame it is in front of the collider, in the next frame it is already behind the collider, because of its movement speed. Maybe try using a BoxCollider2D or modify the size of your Collider. Maybe this solves your problem… or maybe not ^^
Continuous collision detection doesn’t work with triggers. Continuous means a body will be swept during its move and be positioned at the first collision point but triggers don’t cause an object to be repositioned so it’s not relevant to them. You can still tunnel through a trigger.
Being static or any other type is irrelevant to continuous collisions.
I had come to that conclusion MelvMay, thanks for your reply. When you say you can still tunnel through a trigger do you mean manually by calling a sweptcircle test or is there a built in solution?
I have moved to using my own spline calculations for determining lap counting etc but no doubt I will want some triggers to be handled correctly for other items.
I’m talking about Continuous collision detection for Rigidbody2D only and not queries. Any “cast” query though is by its very nature a continuous collision detection but it’s nothing to do with that. The problem you’re referring to isn’t the collision detection, it’s the tunnelling so it’s the stopping and Rigidbody2D don’t stop with triggers. A collision is only reported where the Rigidbody2D stops during the simulation step.