Capx : https://www.dropbox.com/s/lgqw6b0895ewzq4/sheepherder.78.capx
Moments after the start of the capx you can see the problem, the sheep reaches the dog and instead of stopping or moving away from the dog (The latter more preferable than the former... but either would help!) the sheep sits there and proves Schrodingers' cat was an amateur.
The sheep immediately trys to exist in both the state of toward the dog and away from the dog at the same time. I can't seem to get the sheep to pick one state or the other.
I'm trying to get the sheep when "afraid" to move away from the herd object. Ergo, the Hdesire and the fear equation: (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) Which SHOULD increase the "fear" the closer the dog and sheep get to one another until Hdesire (the desire to herd up) is much smaller than the desire to run from the dog.
With Hdesire at 10, when the dog closes to within 90 px of the sheep, it should switch to "fear" and stop "herd".
Instead it sits and spins, even when well within the 90 px range.
1. How do I fix that, force it into only one state, not both?
Also: Adding a while in any of the three sheep functions crashes the game. All you get is a blank grey screen, or if it works, as soon as the event is triggered it locks up.
2. I can't seem to get C2 to compare to global variables. If I try to declare fear to be an equation (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) it won't store the value and defaults back to 0. If I set an On Start of Layout fear = (100-(distance(dog.x,dog.y,sheep.x,sheep.y))), it will not bring fear up as an option when I want to compare to variables as a system action.