ID:161926
![]() Mar 14 2008, 4:45 am
|
|
I was trying to think of a way to force the movement of a mob, if they are standing still. Reason being, I don't want 50 mobs lined up in a line, I'd at least like them to move a bit, it just looks nicer IMO. I tried making a variable, and setting/unsetting it on move, and in the AI, if it was set to one, then move and set to zero, but that didn't work real well. Any thoughts?
|
You had the right idea about modifying a variable when a mob moves, but instead of being a boolean that variable should store the last time a mob moved.
Here's what I'd do (untested): mob If you want the gap between each movement to be random instead of a set 10 seconds, you can replace this line
if(last_movement_time + 100 < world.time)
With this:
if(last_movement_time + rand < world.time)
Where rand is the time it takes being idle to automatically move in 1/10th seconds. |
Compare the current time with the last time they moved and calculate their chance of moving based on the length of time that has passed.
Alternatively use a perlin noise generator to control movement frequency possibly.