Game Development Community

Avatar/AI Grouping behavior

by Igor G · in Technical Issues · 04/25/2007 (1:30 pm) · 2 replies

Hi,

I have a bunch of NPCs following my player. My follow code basically gets a vector from the NPC to the player, and calculates a new move destination every few milliseconds:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6673

This works fine with 1 NPC following my player, but if you spawn a couple more, maybe 10, then the NPCs start walking in a line, each following each other, like a family of ducks.
It's a really weird effect, and I'd like to think of a way to get rid of it. I'm no AI guru, so maybe somebody here can give me a suggestion?

Thanks.

#1
05/04/2007 (12:22 am)
Try throwing in a controlled randomization element for each ai?
#2
07/28/2009 (7:45 am)
You need to look into AI "Flocking".

The NPCs should all want to stay a certain distance from each other, a certain distance near the PC, and they should all walk in the same direction as the PC.

Instead of having them walk towards the way the PC is walking.. Try to have them walk from where they are in the same direction the PC is walking.

There's more to it then that, I don't have time to get into it all right now. Look into "Flocking".