I want to make an NPC AI for my RPG Game that walks in random directions. How to do that?
You can use the pathfinding behavior (pathfinding obstacles for the walls, and the pathfinding for the NPC)
it would look like this:
Remember to set the proper obstacles, and add the status variable to the npc object
The pathfinding node count is to prevent the npc from doing a long walk if the destination is close but the npcs needs to go around a long wall.
It seeks close spots -5 or 5 cells both on X or Y thanks to RandomInRange, and the “32” is for my cell’s size. If you use a different cell size, change this value.
I hope this helps