Weighted blending vs priority groups
Before I go on with the Path follow conundrum, I have a really small demo to show. These basically evolve as I try different techniques and test them. Now that I have a number of working steering behaviours to choose from, I have been trying out mixing techniques again.
To make it short, imagine we have 2 steering behaviours working on an agent: followpath and separation (this one simply accelerates the agent away from another agents if they should get too close). Let’s call these A and B.
Here is how weighted blending works:
- each returns an acceleration as a vector with 3 components
- each has a weight assigned to them
- for example A has 1 and B has 2
- we take their returned acceleration and multiply them with the weight
- we add the results
- if the length of the resulting vector is bigger than a set maximum value, we normalize the resulting vector and multiply it by the maximum value
And here’s how priority groups work:
- we put B in priority group 1 and A in priority group 2
- if priority group 1 returns an acceleration with a length bigger than a set threshold value, we use that acceleration
- if not, we use the acceleration returned by priority group 2
It’s priority groups because you can put multiple behaviours in a group and have the weighted blend of their returned accelerations as the returned acceleration of the group. The idea is that you can make collision avoidance a more important behaviour for example. So whenever there is an obstacle that has to be avoided, the behaviour will take complete control to make sure it really is avoided.
However if you think about it, you can do a similar thing by assigning a very high weight value to collision avoidance compared to pathfollow. This seems to have the benefit, that you can change the importance of the 2 behaviours much easier during runtime.
So in this demo you can see a 3 scene presentation of mixing followpath with spherical avoidance. You can load a scene by pressing 1, 2 or 3 on your keyboard.
Scene 1 uses weighed blending with a weight of 1 assigned to both behaviours. Scene 2 shows priority avoidance assigned to priority group 1 and pathfollow to group 2. Scene 3 is weighted blending again with avoidance having a weight of 10 this time.