AI pathfinding and doors

ikonhero

Member
Hi,

I followed this tutorial on AI pathfinding:

It works quite well. The only thing I can't seem to figure out is how to implement doors into my maze.

I use the pathfinding for player movement through the room, but I also tried using it to go to the door and open it, but since a closed door is added to the list of objects to avoid it makes it impossible for the player to create a path to the closed door (as the doors coordinates are inside a blocked area; the closed door).

I was wondering if there is any good information available on this. I tried searching for a tutorial but couldn't find anything useful.

I basically want the AI to avoid a closed door, but be able to go to the closed door and open it (when asked). I tried something with adding positioning objects to each door, but this gets complicated as a door should be openable from both sides, and one side may be reachable but the other not, etc.

Example of room:[URL=http://www.imagebam.com/image/8d131d547213781] [/URL]

Is there a way for doors to be avoided but be reachable in another way for opening, or in what direction should I be going with this?

Any help would be much appreciated!

Thank you.
 
A

anomalous

Guest
GMS pathing has two states, pathable or not.

If you don't want the AI to go through closed doors, set them to not pathable.
In cases where you want them to go through closed doors, set them to pathable temporarily (for long enough to run the path).

If you want them to path to a closed door, open it, and continue, you can use doors as pathable, but you'll need a collision check, if AI will run into a closed door next step, open the door. If you have to make them stop, you'll need to do a timer, its more complicated but still straightforward. I would simplify it as much as reasonable.
 

ikonhero

Member
I managed to get it to work by creating 2 positioning objects like I said. It was a bit tricky, but it works like a charm now.
Every door creates 2 invisible objects in the create event. The player looks for a path to them when the door is selected. First it checks which one is available and then it goes to that positioning object and the door opens.


 

NicoFIDI

Member
make 2 doors, a openable and a inopenable for the IA
make the pathfind ignore the openable and when it colides the door opens, or you trigger your animation or whatever
 
Top