How do I create a basic simple AI character?

How do I create a simple character, such as a guard, that will walk around and when it spots me it comes towards me to attack.

I know how to do everything else except how to make it just walk around and when it spots me it rushes towards me to attack.

If your using blender 2.5+ you can use nav mesh’s, for movement, if its a shooting game you can then use a ray sensor that looks for your player, and when its positive it can shoot.:slight_smile: hope this give you some ideas:)

Step 1 for simple AI programming:
Divide up the planned code into “states” These can be things like:

  1. Roaming
  2. Spotted the player
  3. Attacking the player
  4. Searching for the players.

This is a lot simpler.
Roaming? Navmesh with the target set to a node that jumps position when the AI get’s near. (to another point on the navmesh)
Spotted the player? Try python for this, things like getDistanceTo() etc. Then move towards him.
Attacking? Play animation/inflict damage.
Searching? Looks where the player last was, maybe spins on the spot, then goes back to roaming.

To expand on what sdfgeoff said, a very common technique for creating AI is finite state machines (FSMs). These are defined by states, and the transitions between states. The main focus is on the state. Each state has a set of transitions with different triggering events. An overall AI system then runs the state machine for each ai controlled character. When you run a character’s FSM you are checking the triggers to other states, and if one is triggered, you change the FSM to that new state. In this way the AI character keeps changing states based on those triggered transitions.

I hope this is more insightful than it is confusing :stuck_out_tongue: