Hi!! Here my problem
I have two ants and two flowers. Both ants have to move to the same flower. One ant has a free way to the flower but the second ant has to ignore a flower in his path.
The flowers has a Variable called ID, the ants has a Varriable called Target with the ID value of the flower. Both ants have the value 1 in Target
My code is like this
The result of this is.
Ant 1 collisions with flower 1 and the ant stops moving. Great!!
When ant 2 collisions with flower 2 stops moving too. Bad!!! Has to go to flower 1 and then stops.
What’s wrong here?
Just a test I made… If I change “SET 0 to move” to “Delete Ant”, the second ant ignores flower 2 and stops in flower 1 like I want to
Your current events basically apply to all ants whenever the conditions are met. That’s why it is applying to both.
You’ll want to look into the “For each” event type, and probably do “for each ant”.
Now I added a link between ants and flowers and made a change to this
It’s working, but, is this the correct way to do it? Because now my event don’t start with a collision, instead of that, I’m always making the “for each of ants” and then checking collisions.
Are more resources used checking collisions in this way?
i suspect that your first approach should be about half as expensive, because it needs to check all ants once. the second approach would be checking each ant times number of ants.
Just a speculation, not sure.