2D Collision checking looks at IsTrigger colliders also?

I have a tree broken into two parts so that the trunk is impassable while the treetop has a Trigger collider (which allows me to make it translucent when something is behind it.) It appears A* is making the tree top impassable even though it is only set to IsTrigger? When I disable the collider, A* does not think its impassable any longer.

Any way to fix this? I use a ton of colliders that are Triggers. I assume I could put it in its own mask layer but that seems a bit cumbersome?

Hi

Yeah, currently I think only 3D physics ignores colliders. I should fix this, but I don’t think the necessary API was available for older Unity versions.
In any case you can disable this globally by going to the Unity physics settings and unchecking the box that says “Queries Hit Triggers”.

I was just looking for this information, since previous posts seem to indicate that triggers are ignored by default. This is not the case for 2D triggers, it seems. Base.cs does not seem to include a query for Physics2D, just Physics.

Anyway, setting “Queries Hit Triggers” in the Physics2D settings resolves this issue, but I’m not sure if it will lead to other problems with my project down the line, as it is enabled by default.

2D triggers should also be ignored on A* Pathfinding Project’s end as they are for 3D triggers.

I just ran into an issue with another part of my project when disabling “Queries Hit Triggers” in the Physics2D settings. It’s on by default in Unity and I’ve been using 2D raycasts against trigger colliders for something else. Took me a while to figure out why a bug was happening and then I remembered unchecking this option.

Do you think that you will fix this issue? Again, when using with 3D projects, A* can ignore triggers (and does so by default) but no such option exists for 2D projects/physics. It’s just the wrong behavior, as 2D triggers should not have anything to do with pathfinding. I’d prefer not to have to re-write other parts of my game to make it work with A* Pathfinding Project.

EDIT: I see that this was fixed for the beta version, 4.3.39 (2020-12-11). I’m going to give it a try and looking forward to it being part of the next non-beta update.

1 Like

For those of you who have trouble trying to get this working in 2D, search “contactFilter” in base.cs should lead you to contactFilter = new ContactFilter2D { layerMask = mask, useDepth = false, useLayerMask = true, useNormalAngle = false, useTriggers = false}; then change useTriggers = true. Now Astar will detect both type of collider. This work for me, good luck!

1 Like