Ceiling pathfinding

Is it possible to use A* to make an NPC have multiple modes such as pathfinding on right side up surface, and then making it path find exclusively on a ceiling.
I have a spider NPC and I want in real time to tell it to start pathfinding exclusively on ceiling for some time then tell it to jump back to ground and path find there.
I bought this only a day ago, so I don’t have a great grasp on this yet, I would appreciate ANY help, this is very important for my spider’s mechanics.

Thanks a lot, so much, for any help!


This is not something that is officially supported unfortunately.
You can create multiple graphs and make the AI decide which one of them to use (see the graph mask parameter in the Seeker API) however it might be tricky to generate graphs for walls since they can have many different orientations.
This would also be hard to combine with smoothly moving between a wall and say the floor.

I only had the code for a day so I didn’t have a lot of time to look into it.
If it was binary, like I would make it just stop, jump down/up, and then pathfind on the current surface (ceiling/floor) would that be possible?
For now I don’t need walls, I need ceilings and floors.
I was hoping this solution would have had this kind of mechanics since it looked so dynamic =[


Yes, that would be possible.
You would create two graphs, one for the ceiling and one for the floor, and then you would switch between them by changing the graph mask (see http://arongranberg.com/astar/docs/class_seeker.php#ab50a876ab529ceb3eb9b97deb5a48d1e).

Thanks a lot Aron, I’ll let you know when I’m done implementing it =]

1 Like

Are you sure its possible to make it work on ceiling aswell (upside down and everything)?
Or would I have to hack my way around that?

Sure, that is possible.
You would just have to rotate the graph 180 degrees around the X or Z axes.
Grid graphs can have any rotation.