Using the Concurrent node to run some functionality OnStop is definetely a correct way of doing it.
OnStop is called whenever the action is stopped due to any reason. So the reason why OnStop is called twice in your case, is because you call EndAction again within OnStop. So it’s called once when you call EndAction and another time when the nested FSM exits.
To achieve what you want to do, you can simply do this:
1
2
3
4
5
6
7
8
publicclassCleanUp:ActionTask{
protectedoverride voidOnStop(){
Debug.Log("Stoped");
}
}
Adding this on a Concurent node and when the nested FSM is exited, “Stoped” will be loged.
Let me know if this works for you.