Hi, I want to have parameters on a nested node such as SubTree in BTs that are continuous read and continuous write. Right now, the variable is only set once when the sub graph starts, but after the sub graph has started any change of the parameter from the parent graph will not be reflected in the sub graph.
It seems there is no built-in way to do this, so my idea is to create custom nested graph nodes. As an example, I will talk about the SubTree BT Node.
As far as I understand the binding of variables happens in the TryWriteAndBindMappedVariables and the cleanup happens in TryReadAndUnbindMappedVariables both of which are located in the IGraphAssignableExtensions.cs
Would it be enough to change the one time write:
if ( bbParam.canWrite ) { targetSubVariable.value = bbParam.value; }
Also adding the matching clean-up in the TryReadAndUnbindMappedVariables method.
This solution seems to work in my first test but I would love to know if I am missing something?
Could this lead to endless event calls (bbParam onValueChanged sets target variable which triggers its onValueChanged and sets the bbParam triggering the onValueChanged -> and so on…)
What were the considerations for implementing a one time write in instead of fully synched variables? Are there good reasons not to do this?
1) You are not missing anything. All the functionality related to variables mapping is basically within those two methods.
2) It should not lead to endless loop since setting a variable first checks if the new value is != to the existing value.
3) The consideration was for subgraph exposed variables to work similar to how code function parameters work, meaning that they are only given once when the function is called. It just made more sense to me to write-in only when the subgraphs starts, but I suppose that an option needs to be added to let us select in inspector a “once” or a “synchronous” write-in (and probably read-out as well).
Thanks for the explanation. For now, I will probably implement variants of the subgraph nodes with my desired write-in behaviour to not mess with the built-in functionality. If you include an option to set the write-in to continuous in the official node canvas package, it would be highly appreciated.
Keep up the good work 🙂
Sorry no, continously writing in the mapped variables while the subgraph is running hasn’t been implemented yet (basically only because it is not something requested that much). Is indeed continously writing in the mapped variables while the subgraph is running what you requeste? If so, I will move that up in priority in the TODO list. 🙂
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.