Advertisement

FPS/RPG AI/Pathfinding

Started by May 21, 2002 11:16 PM
1 comment, last by Qatal 22 years, 6 months ago
I''m writing a FPS/RPG at the moment and it''s going to have a lot of NPCs, both friendly and unfriendly. The environments are mostly space station and ship interiors. i liked the nav point system that was used in Red Faction a while back, and am wondering how best to implement a similar system. i got the idea that every discreet location you can be at has a nav point on it, and a path that''s guaranteed to be free has links between adjacent nav points. how do i do this in code? im using delphi. linked lists? a big static array of "nodes" that can link to each other via pointers? i''m wondering... and then, how do i get characters to use the paths? do i use A* still or does the preferred route system do the A* work mostly for me? and most importantly, how do i make sure that the AI doesnt get stuck and jittery when its moving fast and near a node? i was coding a 3d racing game a hort time ago and for some reason my ai cars didnt registerthat they had reached the next waypoint and kept turning around to head to it. is this just a matter of the "reached" threshold value being too low, or is it something else? i tried putting the value up (well higher than the distance a car could move in one cycle) and it just happened earlier. what''s wrong? my AI for this FPS/RPG is gonna look like crap if i have the same problem with it, so HELP PLEASE... please... Qatal the experienced RTS coder turned rejuvenated noob.... die or be died...i think
die or be died...i think
Hi,

I wont spend long addressing all your questions! But if you have a 3D object which is moving, one solution is to calculate a ''volume'' of space which it has occupied since its last movement.

If you have a bounding-box, you may want to make an elongated rectangle which represents the space that the npc has moved since last turn. With this new ''volume'', you can easily determine whether the waypoint it was supposed to reach is inside this.

Another much simpler method is just to keep track of the npc''s distance to the waypoint. If the absolute distance suddenly got larger, but the npc has not changed direction, then its most likely that the npc has reached the waypoint during its last update.

As for your indecision on how to store the nodes for easy pathfinding, read James Matthews articles on AStar at www.generation5.org



regards,

GeniX

www.cryo-genix.net
regards,GeniXwww.cryo-genix.net
Advertisement
Yay!I code my AI using simple IFs.

For example if a non player controled sprite is blocked by an object i and it''s direction is eg.left i initiate a specfic jiggle mode which makes a sprite to move up or down for few loops....when the jiggle mode is off sprite is now above or below the colliding object and can freely contiune on it''s old path....but that won''t work for large obstacles like walls.

This topic is closed to new replies.

Advertisement