Simple beginner question - testing to improve AI with locked doors

Hi Aron,
Amazing project.
I finally gave up with Unitys pathfinding as i need runtime generation of pathfinding and am in the process of switching to yours, as a way of learning your asset i have been trying to play with unlocked and locked doors in a maze.

My question is:
As you perfectly show in your video, “A* Pathfinding Project Pro” 49seconds in.

When the AI path script’s target is behind a locked room, instead of going to the door to wait like it should in my view, the AI will instead it seems go to the nearest point it can reach to the target, in that example away from the door near the wall.
I don’t want that logic, if it can’t reach the target, it should wait by the door.

So I have been trying to resolve this via:
seeker:
valid tags = ground, Door.
tag penalties = ground 0, door 9999
doors will:
on open apply an updateGraphsWithGUO tag ground
on close apply an updateGraphsWithGUO tag door

This method seems todo the job;

the AI will still navigate to target if its behind a locked door
the AI will navigate around a locked door if there is another way.

My question is 3 parts.
1.) is the the best solution?

2.) it relies on collision detection between seekers and doors/walls

3.) And a point that really got me stuck is I swear to god that i had a rigidbody component on my units because they actived the unlocked doors trigger collider, and stopped at locked doors! However now in my project if i have a rididbody component attached to a unit it refuses to move with seeker and AI path script attached.
Is there a way to move arididbody componets with a*?

thanks for your time, i tried to find the answers to both of these questions on the forum before posting.

Hi

If you want that logic, then yes, you will need to use penalties. So the solution you figured out seems to be a good one.
You could post process the path to remove everything after the first node that has the ‘Door’ tag (make sure this happens before the Seeker sends the path to the funnel modifier, you might need to create your own custom modifier script with an appropriate priority).

When using a rigidbody, the AIPath script tries to move it by using AddForce. This is not a desirable movement mode for some games (it might be better to set the velocity field directly, or use the Move method). You can change how exactly movement happens when using a rigidbody in the AIPath.Update method.

thank for you the reply Aron.
amazing project, i hope to be purchasing the asset down the road on a future project i have planned.

1 Like