Hello. I think this is the correct channel since I’m in trouble with triggers detection. I have a trigger with a script. This script has an OnTriggerEnter2D and it only detects a static collider when it collides partially the trigger.
The blue square is the trigger, and the white wall is a collider. The trigger would detect the collider.
The green square doesn’t detect the collider.
The triggers configuration is in the photo.
Is more information needed?
Rather than drawing over a screenshot, you should turn-on the collider display to ensure you’re actually showing where collider shapes are. You can control this in the Project Settings > Physics 2D > Gizmos. You can tell them to show all the time and even to fill-in the area of the colliders with a colour.
Anyway, it’s more likely that you’re not telling the whole story here and that the “white wall” is a bunch of physics colliders or tiles in a TilemapCollider2D merged together using a CompositeCollider2D and you’ve selected “Outline” (edges) so the only shapes that exist are edges surrounding the “white wall” i.e. there is no “inside” the wall. Edges don’t have an interior but they are super efficient when you’re not interested in interiors of areas and they don’t exhibit problems such as “ghost collisions”.
Lots of tutorials show using a TilemapCollider2D with a CompositeCollider2D for no good reason too. It should only be added when you understand why.
If this is the case and for some reason you need to detect the interior of the “white wall” then you cannot use outlines and need to use the Polygon mode of the CompositeCollider2D or remove it entirely.
If not then you should describe what the “white” wall is. When asking about contacts between colliders you need to show/describe both.
Thanks. I will investigate more about when to use CompositeCollider. You saved me from what I thought was going to take ages, have a good day!
1 Like