The way currentState is designed to work now, is that it returns the State only within the FSM it is called from. Each FSM holds it’s own currentState. Thus ‘agent.behaviour.currentStateName’ will return the root FSM (one assigned in FSMOwner) current State name.
Here is a workaround to get the current state name of the task’s own FSM from within an action/condition task:
1
2
3
4
5
6
7
8
9
10
11
12
publicclassGetCurrentStateName:ActionTask{
publicBBParameter<string>currentState;
protectedoverridevoidOnExecute(){
varmyFSM=(FSM)ownerSystem;//the ownerSystem is the graph which this task is assigned within.
currentState.value=myFSM.currentStateName;
EndAction(true);
}
}
Let me know if that works for you.
I will certainly look after a simple method to get the current state from the FSMOwner regardless of nested or root as well.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.