Blog start
I haven't been blogging since I started with Leadwerks so this blog will be a bit of a catchup until now. Unlike most people working with Leadwerks I thought I'd ignore all the graphic eye candy as icing on the cake and concentrate on the importing matter of making things happen ie. AI
The bacis of AI is:-
Physics
-------
Knowing whats bumped into what. This is already taken care of in Leadwerks.
Sight
-----
NPC's need to have a sense of sight, this is mimicked by doing Line of sight tests using raycasts. In leadwerks you use LinePick, the knack is though where to linepick. I post example code latter.
Pathfinding
-----------
NPCs need to know how to get from A to B. This is a big one and quite complicated. Older games used AI Nodes bit this is now seen as outdated, the thing to use in a modern game is a NAVMESH. I wrote Blitzmax stuff to generate my own navmeshes by analysing the level with linepicks however this proved to be too slow. I dumped Blitz and went onto C++ and intergrated in recast ( http://code.google.com/p/recastnavigation/ ). This library is really good and fast. My NPCs knows now how to get from A to B.
See http://www.ai-blog.net/archives/000152.html
My blitzmax navmesh
Locomotion
----------
Once a NPC knows how to get from A to B they need to do the actual physical move. Moving the character controller along will not derive a quality appearance as it will bump into things, other NPC dynamic moving objects etc. To get the actual controller to move nicely I have implemented OpenSteer on top of the pathfinding. Using combined steering forces allows collision avoidence of moving objects.
See http://opensteer.sourceforge.net/
I am only 80% satisfied with this solution an may abandon it for something better in the future.
A dark video example of navmesh and opensteer working
Animation
---------
To avoid foot skating/moonwalking I play the movement animation the correct proportion of frames to match the distance travelled by the locomotion. I pre analyis the animation sequence to calculate how for a sequence my travel.
Descesion making
----------------
Another big one. A lot of people implement FPS games using finite state machines - a posh was of saying lots of if then else ifs.. I wrote my own FSM machine again in Blitz but decided this did not have the quality I was looking for. I have dropped this for behavoir trees and I am using a library called A++.
See http://forums.aigamedev.com for more info on BTs and A++
I can't comment any further than as this is as far as I've got, I am currently implementing all the different behaviours for my AI.
2 Comments
Recommended Comments