Include Trigger Colliders in 3D Grid Graph

Hi,

I have been using the pro version of A* Pathfinding Project for my game and it has been going great! Recently, I have needed my agents to path around certain trigger colliders using a 3d grid graph. Up until now, I have had no issues pathfinding around non-trigger colliders, but it appears that as soon as I set a collider to trigger the agents ignore it (and subsequently path right through the trigger area). I have searched for previous answers and have found that in the past people could ignore trigger colliders by changing the Physics settings, however I don’t see any answered topics requesting to include trigger colliders in the grid graph.

This behavior is vital for my game because there are areas that the agents need to avoid but those areas don’t physically collide with them (as they are triggers). I have checked that the colliders are in the correct layer and that simply switching a collider to trigger is definitely what causes the agents to ignore them. What is the best way to address this issue?

Hi

The package is currently hard coded to ignore triggers in all forms. Usually people never want them included in the graph. You could solve this by either making an actual collider, but change which layers it collides with, or you could use a GraphUpdateScene component (see graph update docs) as an alternative way of modifying the graph, or you could open the Base.cs script and find all instances of QueryTriggerInteraction.Ignore and change that to QueryTriggerInteraction.Collide or QueryTriggerInteraction.UseGlobal.

Using QueryTriggerInteraction.UseGlobal fixed it! Thanks for being quick and responsive!

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