Simple roaming AI template for dungeon RPGs. (Updated)

If you want to get your enemies to roam randomly around your simple maze.

>>>EDIT see the second post for an updated version 2.0

Here’s a file for testing:

and here’s a preview of the result on Youtube:

Need feedback so I can improve it. Enjoy ^^

Benefits: Fast and resource efficient, can work with a dozen or more objects with little slowdown. The name and shape of the follow nodes doesn’t matter, just any object with a property of “node”

Drawbacks: Pretty stupid AI, Doesn’t track the player yet (wait for version 2), has a tendency to bunch up when you get more than two enemies close together… needs quite a few nodes.

I’ve now worked up version 2.0
It has track-to player and I’ve made it so the objects have a little more “give” on the x-axis. It allows them to slide a little on walls and cuts down instances of them getting stuck.

I may go back and key the major variables such as speed and tracking speed to object properties to allow more customizable usage, but for now this is a nice workable template for anyone needing an indoor RPG Artifical inteligence.

It’s still not that smart, but it doesn’t take as much resources as some of the A* stuff I’ve seen around on the forums. You may want to consider this as an alternative which better suits the limited resources of the Blender Game engine. I’ve seen a lot of projects abandoned because they tried to be too advanced, sometimes it’s better to have something that works, rather than wish for something that works better, and have nothing.

Here is a preview on youtube:

and a download for the blend file:

It’s looking good. I’m sure it will come in handy for future game projects.

I haven’t looked at it closely, yet. Does it allow for roaming way points and/or boundary zones? Is there a way to make the enemies stop chasing after you get a certain distance away from them and they are outside of their normal patrol area?

We could make a little game in some hours with this template!
Thank you very much for sharing!

Thanks, version 3 will include an inventory and weapon switch template (which I’ve already got working in another file, just needs to be integrated), and version 4 will include combat/death system and a save point system.

if you enjoy the template please spread the word so more people can find it.

I’ll also do a short tutorial at some point on how to add your own nodes to a custom map.
The enemies use a ray-cast to player to check if they see it. If they can’t see it and they become stuck against something, they go back to patrolling.

Interesting, I havent had a chance to look at the .blend, but Im guessing this wouldnt work for a randomly generated maze? Would it work for a more dynamic setup like a maze which is made up of many random maze parts which scramble each time the game starts?
If I had a maze setup already, what would I have to do to get this system working in my own .blend and how tricky would it be?

This is very nice work, thanks for sharing it :slight_smile:

Hey, I’ve updated this again, but can’t post at the moment because I don’t have internet at home right now.

The new version is a “motivated” random maze wandering script. Now the enemies can be guided towards an end point, either moving (the player) or static.

will post it soon.