|
|
Reply to Message
Not registered yet?
The AI Depot has a focused community of friendly users. Rather than let anyone abuse the site at the brink of promiscuity, we prefer to let only those with an active interest participate... this simply requires registering.
Why not sign up!
Joining the site's community is completely free. You can then post messages freely, and customise your personal profile at will. Specific privileges will also be granted to you, like being able to access printer-friendly articles without restrictions. So, why not register?
Parent Message
Help Needed in AI in 3D Games
Think I can help you on your way... For the following, I'm assuming that you are already able to make the enemy walk and turn. Easiest way I can think of, is using a waypoint system and a state machine. Waypoint system: You specify locations (waypoints) in your environment (ie. in a level editor), and for each location you specify the connections to other (nearby) waypoints. This way you can create a grid or paths your enemy can walk on. Good thing about this is that you don't have to worry about collision detection (at least not with the static environment) State machine: Can be implemented as a switch/case statement. You will need about three states: Guard, run, attack... A short (pseudo code): switch (currentState) // Check whether to change to another state case STATE_ATTACK: if (distanceToPlayer < 3.0f) case STATE_RETREAT: // WalkAway should disable state machine until a certain distance (ie > 5.0f) Note that the above piece of code is missing something trivial: Pathfinding. Easiest is to implement WalkAway something like this. void WalkAway() Hope this makes any sense! If not, drop me a mail on [email protected] |
|
Back to the AI Foundry.