For testing I am creating a flock of Critters (a subclass of GKAgents) in a loop, each critter has 3 goals:
- Seek (Weighted at 0.05)
- Wander (weighted at 1.0, but disabled as I can't get it to work)
- Seperate (Weighted at 10.0)
As I create each Critter I add them to my flock, what I am puzzled by is the way that goals (like seperate) that require an array of agents work at runtime. When I create each Critter (and its seperate goal) and add them to my flock this is what I will get
- Critter_001 - flock[]
- Critter_002 - flock[Critter_001]
- Critter_003 - flock[Critter_001, Critter_002]
- Critter_004 - flock[Critter_001, Critter_002, Critter_003]
- Finally arriving at - flock[Critter_001, Critter_002, Critter_003, Critter_004]
As you can appreciate if this list is taken as-is at creation than Critter_001 has no one to seperate from and Critter_002 only seperates from Critter_001. I would hope that on each cycle of the update loop the goals look at the current state of the flock. If this is not the case then it could be very limiting as the entire flock would have to be setup initially (before any goals) as the first Critter into the flock needs to know about the last. It would also mean that killing off Critters would potentially slow things down as other Critters could be trying to look for / avoid flock mates that no longer exist.
Does anyone know, or have they spotted anything in the docs / examples that explains how this works.
EDIT: I am pretty sure now that the list of GKAgents in the flock is set when you actually create the goal and can't be modified later by adding to the array. If you look at the image below you will see that the other agents show some notion of adjusting their paths to seperate from other flock members. Critter_001 on the other hand defaults to a circular orbit of the goal as he is blissfully unaware of any of his flock buddies ... sad really 😟
https://goo.gl/photos/dpWzBbwdDzHzNK5o6
OK so how do you get picture to show, it shows above in the edit, but is gone when I view after pressing [Post]? *** Ye olde link added instead.