Sample source for the leader follow steering behavior

Started by
12 comments, last by unsigned short 16 years, 1 month ago
Quote:Original post by unsigned short
Thanks for your answer. I tried out your solution, but now it doesn't work at all. Perhaps I'm doing something wrong ...

I think the best is to post the complete code. You only need SDL to compile. The unit.bmp is a simple 32x32 circle image.

Here it is!


I'm sorry but I don't have time to review your complete code (nor install SDL)... the teaching semester is about to start and I'm flat out. I'll do my best to come back to this when I have some time, but I cannot promise that will be any time soon. Sorry.

I hope you're able to locate your problem soon.

Cheers,

Timkin
Advertisement
hm ok i see. I really appreciate your help :)
I'm gonna look around to find a solution. If someone finds a bug in my code, please help me :D
A few quick questions/points of interest:

1. Have you tested the steering behaviors individually yet? Test the arrival behavior by itself using a single unit to verify that it specifically isn't the problem. Test only the separation behavior with a few units starting in close proximity to make sure that they escape in the expected directions.

2. Your description of the problem is kind of vague.....but it sounded like they are following the leader and separating, but just jittering around as they do it. Have you considered that your weighting of the two steering force vectors isn't balanced properly? Perhaps the separation behavior is overpowering the arrival behavior by too great a margin? Weighting multiple steering behaviors against eachother to achieve a desired result tends to be a process of incremental tweaking.

3. Some jittering is to be expected from certain combinations of steering behaviors. An easy solution to just average a unit's heading over a certain number of previous frames to eliminate some of the unnecessary back-and-forth.
1. Yeah I tested them and they worked fine.
2. Yeah thats pretty much the problem. When the units are moving, they are like bumping together repeatedly / jittering around. When they are reaching the target location, they keep jittering and don't come to a standstill. Might be that the steering forces are not balanced properly. I tried out some values but when setting the separation too low, they are crowding together.
3. I read about that approach and it seems pretty reasonable because it smoothens the movement. I also tried to implement it some time ago. I added an array of velocities and calculated the average. But it didn't change anything :(

This topic is closed to new replies.

Advertisement