Just wondering what is the best way to handle this.
So lets say I have an action which encapsulates spawning objects, now I want to maintain state between calls so I can remember how many objects have been spawned, so are actions instantiated per invocation or are they kept around for the lifetime of the tree?
So on the flip side of this, is there a best way to reset the state of an action?
I can always just reset stuff before or within the EndAction() method, but was not sure if there was some preferred way to do so, as I am not sure if OnInit is called first time the action is created or every time the action is re-used after its ended.
OnInit is called just once before first execution, so it’s not a good candicate. It’s best to use OnStop since that’s called whenever you call EndAction or the Action ends due to any other reason, like being interrupted for example.
Or you can reset some variables within OnExecute which is called once on EACH execution. Depending on what you are after.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.