I’m a bit confused on a very simple issue I’m having with my FSM.
Let’s say I have two states, A and B. There’s only one transition from A to B and it’s a Probability Condition.
I want state A to execute all its actions and then check for the transition (so, I set the policy to Check After State Finished). If the probability condition returns true, it should switch to state B.
And all this is simple and works and makes sense.
The problem is: in case the condition fails, I want state A to “restart”. I can’t connect a node to itself, but basically that’s what I want to do.
I also tried “Repeat State Actions” but this way it never checks for the conditions if I set the policy to Check After State Finished.
An approach would be to make the state a behaviour sub tree.
The sub-tree contains a sequencer with your action nodes, followed by your condition node, and fails on condition.This will achieve the Repetition.
On the state itself specify the Success Event parameter, use the Check Event condition to your next state. Now when your original state ends up passing the probability condition, the success event fires, and your FSM transitions.
This is how I would solve it, though there may be simpler ways.
Are you trying to execute a method for as long as the condition is false? You could use “implemented actions” and just return Status.Running. You can keep “Check Continuously” set. Another state is only going to be triggered if your condition returns true. And when it does return true when the FSM first starts, the method gets executed at least once before it makes a transition.