AI Wandering?

Okay, I’ve been experimenting with the new navigation mesh and I must say I’m impressed. Used correctly, this can make pretty decent AI. I messed around with it, and created a couple test files. Now that I know how to use it, I’m planning on using it for the AI for my game. But my question is, how could you make the AI wander around randomly? I was thinking of using a script that would pick a random face on the navigation mesh, and then make the AI walk to it. (If thats possible?)

Help would be very much appreciated, because this is for my high school programming club, and we’re making a game in blender

I think the python API would allow you to pick the object that the AI will seek and find a path to.

So you might create a script that contains a list of objects and picks an object at random for the AI to seek to.

See this page where it has functions and attributes available for the navmesh and the steering actuator.

Yeah, that works, but it seems impractical to have a ton of empties & pick one at random. Is there a way to have a single empty and then use a python script to move it to a random location on the navigation mesh?

What about using a similar technique that someone (I can’t remember who) used to create a particle simulator? In other words, instead of having a bunch of empties or boxes, maybe you can use a single obj (ie, box or cylinder) for a specific area and have the script randomly choose a location inside of the object for the AI to seek to…

This, in my opinion, would be so much more efficient because it’ll save space, look a lot cleaner, be easier to use and other AI can use the same wander-area objects. Not to mention, being able to quickly categorize new objects by their properties instead of names and loads of logic bricks. And, there could be a central controller object that’ll get the information needed, and the rest is history (mostly because I don’t feel like continuing lol). But, you get the idea… What do you think?

Yes that is basically along the lines of what I’m thinking. Except, there is no need to use a 3 dimensional object and then select a random point within the volume of it. I just need a way of getting a random point on the surface of the navmesh. This is the most practical way that I can think of doing it, though I’m sure there are other ways.

If you would like to to add some “Intelligent” in to that A wandering. Would it work if you made a few various task functions (look in to window, drink water, open/close door, etc…)

Then within the range or AI’s view it would seek which of those tasks are nearby and would randomly choose from those?
It could be based even on sounds or such.

To add on to that, I’d love to see AI interact with their surroundings in different situations. Like, if you were chasing a smaller foe, or an enemy with very low health, they can run in a room and lock or block the door… or even block the exits of a previously open room.

Better yet, imagine chasing a pedestrian on a game like GTA… Then they could run into a building, up the stairs, into a room, lock the door… act scared. Then you break in, then they’d jump out of a previously closed window, and the pursuit continues on the rooftops of a populated rural area. (I would play a single level for months if AI could do stuff like that lol).

My imagination gets the best of me, sometimes…

Haha I dont think I’ll be doing AI like that any time soon :wink:

But does anyone know of a way to do this???

Honestly, I’m just starting out with AI and navigation meshes (thank God for 2.6!), but I don’t think it’s too hard… But, I bet I can do it within a few months if I finish my two projects and further learn website design haha.

Random: If you want to see my most current projects, let me know.

Yeah I know. Before navigation meshes, AI would have been impossible for me!

What I was talking about wouldn’t be too hard to accomplish. You could read items in to list with radar or such which an AI can interact with and then you could simply randomly pick one task from those. It may sound difficult but the most time would go on increasing the amount of things to do.

Definitely true, but I have a feeling we’re forgetting something… Oh right, the purpose of this thread lol.

I’ll work on an example blend. Sorry, this may take a while since I’m experimenting with it at the moment. But, when I get a clean, versatile and solid example, I’ll post it.

Okay good, thanks for the help!

Bump… Any ideas?

I’m actually working on it as I text… Patience, my friend. I’m learning along the way lol. (This will be my first AI)

Since it’s taking a while, allow me to explain what’s going on to ease your mind a little.

The past few days have been dedicated to the main character - getting things working properly. I’ll admit, I’ve gotten it working, but there are still bugs…but they’re small.
Yesterday was actually the 1st day of writing for the enemy. Today, I’ve been working on it nearly nonstop (until I went shopping, cleaning and etc). 14 hours (and 36oz of Trail Mix lol) later, here I am. Red eyes, messy hair and cotton mouth haunt me… and I still have enough energy to continue and use my stale sense of humor lol.

Edit: I’ve just been writing the code for the AI - I haven’t tested it at all yet.

(I should totally start a blog…)

You’ll be the first to know when I finish, believe me.

Man, that sounds awesome - a little out of my league, but cool nonetheless lol. I haven’t gotten my AI working yet, so being able to have my AI ‘roll up on a sucka with his posse’ is not going to happen any time soon lol. If I can get it working by later today (it’s now 6am), I’ll make it more advanced.

Almost there… Just got the AI to find random positions. It’s buggy, so I’ll work on cleaning it.

As long as there is nobody competing yet, it won’t be out of your league. :slight_smile: (one entry equals guaranteed the winner! :stuck_out_tongue: )
Also due to very different projects which might result, which in turn might vary a lot, I 'd say every entry might end up a potential winner. :smiley:
It is up to the judges, and while you are on this anyway, why not sign up. :wink:

Very cool, keep us posted! :slight_smile:

Finding AI points.

If you’re interested in finding points on the navmesh at random, then have a look at this.
I was thinking about this myself, and his solution is very similar; find a random polygon and then a random point within that polygon. Obviously the area of the polygon will play as bias; otherwise if you had one LARGE polygon, if it was chosen at random it would be unlikely that you would get positions within that polygon very often. So using the area as bias would allow you to weight it slightly.

This guy is the author of recast and detour. Recast is the navmesh generation tool, and detour the pathfinding library. it’s quite interesting! (his name’s Mikko if you’re interested)

Actually… I FINISHED!!! :smiley: I’m so proud of myself lol. I lost cool points asking about disabling parents, especially since I found out 5 minutes later, but I’m good now.

I’ll upload the blend later. Anyway, here’s a brief description of what I’ve done:

The main player can walk and run to wherever you click, depending on which mouse button is tapped. (Slightly buggy)
The enemy will chase you at a certain range…
If you aren’t within that range, he’ll wander around a specific area. (Slightly buggy)
Also, if you outrun him, he’ll give up and wander.

Pretty awesome for my first AI, right? :wink: Well, I’ll let you be the judge of that later…
Oh, and I plan to make the AI a little more intelligent since I’m this geeked about it.