binaryprogrammer
New member
I'd like to have a herd of animals that move together, but also have individual needs/behaviors.
A quick example would be a player trying to herd some cows from enclosure A to B. During this walk the cows "flock" together, but some cows see food, the cows that are farther from the player should try to get the food, while cows closer to the player have a greater need to obey so they continue to enclosure B.
I'm thinking that in this example, I could use one global flocking behavior anytime a cow has to move and has a neighbor.... so here in your flocking script:
That handles the problem of a herd of 1. But there are also times where a cow has neighbors but also breaks from the "group think" and becomes an individual and I'm not sure how to make that transition.
He can't be removed from the group flock behavior entirely when he's an individual, the other cows should still treat him like he's in the herd because he might be standing in the middle of the herd, but his goals now serve the individual instead of the group.
Or would it somehow be better to go the other way and only have individual behavior trees on all the cows and try to sneak in some alignment, cohesion, and separation rules?
Thanks!
A quick example would be a player trying to herd some cows from enclosure A to B. During this walk the cows "flock" together, but some cows see food, the cows that are farther from the player should try to get the food, while cows closer to the player have a greater need to obey so they continue to enclosure B.
I'm thinking that in this example, I could use one global flocking behavior anytime a cow has to move and has a neighbor.... so here in your flocking script:
C#:
// Don't move if there are no neighbors
if (neighborCount == 0)
{
//use individual behavior tree here for movement?
return;
}
That handles the problem of a herd of 1. But there are also times where a cow has neighbors but also breaks from the "group think" and becomes an individual and I'm not sure how to make that transition.
He can't be removed from the group flock behavior entirely when he's an individual, the other cows should still treat him like he's in the herd because he might be standing in the middle of the herd, but his goals now serve the individual instead of the group.
Or would it somehow be better to go the other way and only have individual behavior trees on all the cows and try to sneak in some alignment, cohesion, and separation rules?
Thanks!