I updated Node Canvas a couple days ago to the most recent version available on the Asset Store. I was refactoring some significant portion of other code so I didn’t noticed that FSM stopped working and found out this yesterday.
Nothing happens after calling StartBehaviour(), the start state doesn’t rund and the whole FSM is dead. I reverted to the previous version and everything started to work fine.
It seems very weird that nothing happens at all instead of something is happening but wrong.
Can you please describe your setup in detail? For example where The owner and the FSM game objects live and whether or not you instantiate them etc.
Also if its possible please send me a project, stripped from anything you don’t want to share so that I can take a look.
If that is not possible please post a screenshot of the FSM at least 🙂
I stripped most of the assets and code. It compiles and runs the FSM with the older NodeCanvas. With new one the FSM doesn’t start (as in the project).
Just run the project, find PlayerCharacterController and FMS attached to it. The deafult state doesn’t run.
Thanks for taking the time to upload the project.
So the issue is due to a change made in FSMs after 1.5.8 version.
What happens now, is that an FSM will automaticaly stop/end if a state has been entered, finished and also there are no outgoing transition from it at all. Which is the case for your starting state “PlayerIdle”.
The FSM actually starts, executes owner.PlayerIdle() then instantely finish since the state finish and there are not outgoing transitions at all.
There are 2 options here:
1. Comment out the code that does this behaviour. In FSM.cs comment out lines #50-54
2. Force the state to never finish, by adding the “Run Forever” action in the list.
The reason this behaviour changed from 1.5.8 is for when using FSM as nested to other FSMs or BTs so that an FSM actually ends sometime and the parent graph continues. I think I will revert the previous behaviour though, since there were more people getting confused by this. So feel free to just use the first solution if you like.
Thanks, will do that. Actually the way I use FSM it’s probably better for me to switch to another, strictly code-based solution as I use a very basic functionality your FSM (not transitions, custom functions, etc.) But it works for now so I’m happy with it.
After 3 weeks of pause I returned to my project and decided to stay with Node Canvas. Unfortunately something is still wrong despite the resolutions you provide. My scripts are ended immediately instead of being run as coroutines.
If I comment the lines you suggest, the state is finished immediately (green checkbox).
If I keep your updated code and and Run Forever action, the state is running (yellow clock) but my coroutine isn’t.
Either way, this doesn’t give me previous behavior. It seems that Execute Function doesn’t event execute my function.
Ah, now I understand. The problem you are having is with the Execute Function task executing a coroutine.
This is a bug indeed that only recently found out. Here is the fix for Execute Function:
Open ExecuteFunction.cs and at line #92 you should see that the EndAction() is called.
Simply move the EndAction call within the bracket just above(within the ‘else’).
From this: