Game Development Community

Crowd/mob behavior code

by gamer · in Technical Issues · 09/17/2007 (4:11 pm) · 1 replies

Has anyone done or know any crowd/mob behavior model/code that I can reuse?
thanks

#1
10/19/2007 (3:17 pm)
Not I. But it can't be very hard. All you have to do is make the bots all respond to an event in a similar manner.

Say, you have an explosion. If the bot is close ( < 15' ), it falls over, gets up, and start running for his life. If he is a little further away ( > 15' ), he starts to run. If he far away ( > 300' ), he runs toward the explosion to see what's going on. For more realistic behavior, there would be a "random" zone ( > 250' < 300' ). If he is inside this "random" zone, then he "randomly" decides whether he should be interested or running for his life. Another realism factor would be if an interested bot "meets" ( gets close to ) a scared bot then he gets scared too.

Once you have the code working for a handful bots, add a couple dozen more and see what happens.

Best of luck!