Some Simple AI Behaviors

Hey guys, I was messing around with Unity 3 for the first time last night and put together a simple test level that includes a couple of different common AI behaviors. I thought maybe someone could get some use out of it, so I decided to post my project. If you’re interested in creating some simple NPC AI behaviors but don’t really know where to start… this might just help you out. No promises though. :slight_smile:

Click here to check it out.

Hi,

This looks pretty cool. I ran through the webplayer version and will definitely check out the project (not at home at the moment). I plan on adding some wandering monsters to my game I am working on currently (offthepathgames.com) so this might be just the trick. I was reading part of the blog where you were discussing adding on to the AI by having them point at something rather than just straight ahead and was thinking that should be doable (by someone like me who might mess it up!) to have it point at a target rather than the way it is now.

Thanks!

Calvin

Hey ty. I’ll check it out. Always interestd in AI.

Thanks SPG… any good AI help is always interesting! :slight_smile:

This should definitely be doable. I’m pretty sure there’s some kind of aiming script already included in the Bootcamp demo, and there’s always the headlook example - both of those should be solid resources in getting this done. Good luck!

Steve

A cool technique for these soldiers would be a Subsumption Architecture for the AI.

Pseudocode I have in mind:

while( true )
{
  [FSM Layer 0] - Pathfinding
  {
    Location to move to = Find Path Somehow;
  }

  [FSM Layer 1] - Individual Objective (Follow Player, Patrol with Buddies, etc.)
  {
    Location to Move To = Dot( Location to Move To, Other Position I'm keeping track of );
  }

  MoveTowards( Location to Move To );

  yield;
}

I haven’t downloaded your project file, but I’m having a great time with Subsumptive AIs in Zombies vs. Knights; it’s proving so effective, I’m berating myself for not having tried it before.

I haven’t had a chance to try out a subsumption architecture in a game yet (only a project in college), but it’s on my list to try out for a while. Maybe I’ll give it a shot and post another project…

I dropped wander code on one of my characters and now he wants to fly up in the air! Is there a way to control which axis they are using?

I should add that the follow behavior works fine.

Why follow AI ignore collisions when the surface is not flat

Very nice!

I especially like the guy that follows you if you go too far away from him! I’ll be checking that out!

This is good. I was working with it, and figured you can use CharacterController.SimpleMove(Vector3). I adds gravity, collision and movement.

If you guys are having trouble with non-0 y values you should read the threat started by Luke in the comments section here. There’s a bug in the code:

http://www.stevegargolinski.com/some-simple-ai-behaviors-in-unity/

I know this is very old, but I just updated this project to deal with y-values better because I keep getting emails about it =)

drop box down :frowning:

Congratulations! You have won:


:smile:

3 Likes

cool but this is not what i digged for

It’s the result you deserve, not the result you need.

1 Like