Thanks for the very detailed info. Actualy the internal state of the action, like the ‘latch’ flag, is reset when the state exits. I *think* the problem here is that your callback is called after the state (and thus action) execute is called in the frame.
All update calls in NC are comming through the MonoManager class.
Can you please try puting the MonoManager script in a positive Execution Order through “Edit > Project Settings > Script Execution Order” and let me know? I asume this will fix the problem.
Also, I would suggest that you unsubscribe the callback in OnStop method to make sure that it unsubscribes whenever the action is stoped for whatever reason (state exit, FSM stoped). For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
publicclassFoo:ActionTask
{
privateBar bar;
protectedoverride voidOnExecute()
{
...// something like initializing bar
bar.onCompleted+=SomeCallback;
}
protectedoverride voidOnStop(){
bar.onCompleted-=SomeCallback;
}
privatevoidSomeCallback()
{
if(bar!=null)
{
EndAction();
}
}
}
Let me know if this works. In general the goal is for EndAction to be able to be called from anywhere, yes 🙂