I have a sub FSM (asset graph) on a parent FSM (bound graph). I have a custom action task on one of sub-graph nodes. This action task has a public BBParameter<IPhysics> field, where IPhysics is an interface that I am implementing on a component that is attached to the same gameobject as my FSM Owner. As a sub-graph is implemented as an asset graph (doesnt seem to be an option to implement these as bound graphs), I cannot just drag and drop my component that implements IPhysics over to my BBParameter field on my Action Task. Having a look on the forums (there is no documentation on this topic), I noticed that you can create ‘Exposed Public’ blackboard variables on the sub-graph, and then set this variable and flag it as ‘WriteIn’ on the sub-graph node in the parent graph. My understanding is that, in theory, this allows you to directly access scene objects/components in the sub-graph via this exposed public variable. Trouble is it is not working for me. The sub-graph exposed public variable never gets set – it is always null. Am I missing something? Note that I tested an alternative to the above by not using sub-graphs at all and the FSM works fine in that scenario.
In addition to the above, it would be great if we could have bound sub-graphs. It doesnt really make sense to me for sub-graphs to be implemented as an asset-graph. It’s fine to have asset graphs – but when they are placed inside a bound parent wouldn’t they inherently become bound/instantiated as well?
So the above is working now. All I did was delete all existing gameobjects in the scene that had the above FSM on them and then instantiated new ones at run time. Must have been a problem with asset graphs not updating when I made changes to the FSM. Deleting them and recreating them fixed the issue.
Indeed, you can flag graph variables as exposed public and then write in to them using the Variables Mapping controls in the inspector of the subgraph node in the parent graph. The Write In takes place once every time the subgraph is executed from the parent graph. If you re-encounter any issues with that please let me know since you definetely should have to delete/recreate to fix any issue. Bound sub-graphs is on the big roadmap but to be honest it is not in very high priority in comparison to other things since the only downside asset graphs have is that they are unable to hold scene object references, which is solved using Variables Mapping, but on the other hand they have a lot of advantages, like the ability to re-use them at will and not being bound to any scene.