I’d like to use NC to visually lay out a node graph for generating a sequence of events for our game. Thing is, I want to run this FSM instantly, until it terminates, and just queue up the events in a list.
Here’s a mockup of the type of structure I would like to create. Each “Action” will be a custom ActionTask that adds some element (an event, or “day” preset) to a list. Something like:
1
2
3
4
5
6
7
8
publicDay day;
OnExecute()
{
agent.listOfdays.Add(day);
}
Is there any way to trick NC into running through the FSM all at once, without waiting for updates? Basically I just want to use NC as a visual editor for an abstract graph :).
What you are after is possible already considering I understood corectly.
You can set the FSMOwner’s option on the inspector to “Do Nothing” OnEnable.
Then at any given moment you start the FSM using:
FSMOwner.StartBehaviour(); (or any overload of that).
The FSM will start, traverse the transitions based on the conditions and as soon as it reaches a finished node without any outgoing transitions the FSM will automaticaly stop.
Is that what you are after, or something you tried but it’s not what you are after?
The FSM will start, traverse the transitions based on the conditions and as soon as it reaches a finished node without any outgoing transitions the FSM will automaticaly stop.
Will it traverse the whole FSM in a single frame? I was looking through the code but I got the impression that NC performs at maximum a single transition per frame..
I guess I should just try it, haha! Apologies for being lazy. I’ll get back about this!
Debug.LogFormat(agent,"Executed AddDay ({1}) in frame {0}",Time.frameCount,this.name);
EndAction();
}
And the state machine of the previous screenshot. I get the following:
Showing that the Nodes are executed in consecutive frames. The downside of this is that I’d need to work around _not_ having the timeline ready in the first frame. But I suppose I could just generate the timeline “on demand” as well.
P.S. though oddly, the first two states are executed in frame 1?
Sorry for the late reply. I was mostly away in weekend.
Yes. They are not executed in one frame. I didn’t realize this is what you were asking :). It will required a lot of tweeks to make that happen, but I don’t think that would be an issue for what you are after.
One thing that might help you, would be to start the FSM with the overload that takes a System.Action parameter, so that you get a callback when the FSM is finished after x frames and then use your timeline created in the FSM, which will be “ready” when the callback is called.
Let me know if that helps.
Cheers!
(PS: Regarding first 2 states execution, it seems weird to be on the same frame. I will take a look at this)
I think it would be good to have FSM evaluate instantly instead of ticking through, I think it is more expected behaviour. One could always do a new FSM state that does ticking, but it is not possible to get rid of ticking with new custom FSM state :/ Or is it?
I strongly believe that FSM states should be ticked per frame, considering that the FSM is indeed used as different States of a character/object rather than States representing actions one after another in a visual scripting fashion 🙂
Also ticking the whole FSM in one frame, can very easily cause recursion problems, since the transitions can lead to an already executed state. Of course this can be checked and avoided but then the behaviour of the FSM will not be consistent and probably would be a pain to debug later on.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.