trying to set up an FSM, not a proper coder myself, but shouldn't this work? I'm getting somewhat unpredictable results, like entities not moving or not stopping, some times firing, sometimes not.
Develop games in your browser. Powerful, performant & highly capable.
If i remember correctly triggers fire off independently of conditions they are placed in so they should be on the outside of the condition. Try putting the "On" triggers on the out side of the condition and the if(idle,approach) inside them.
Unless an instance is picked distance() will only use the first index of the object given.
To cycle over each instance you can use for each. It is cpu intensive, so use sparingly.
You could possibly use the los behavior instead.