I’m trying to use a custom node that extends from RouterEventNode<Collider>, but this issue is also present with the built-in Collision Event node (Events/Objects/Collision and any other node that extends from RouterEventNode<T>.
If I use these types of nodes inside a Macro, there’s no way (as far as I can tell) to set the target variable. In a regular graph I can expose it and set it in the inspector, and for most other node types I could set it up as a flow input, but for these nodes there’s no option to do that.
Am I missing something, or is there no way to use RouterEventNode<T> nodes inside a macro and also set their target variable?
Example without a Macro (working):
Example with a Macro (not working, unable to set variable):
The same thing happens with Blackboard variables from what I can see. If this isn’t possible to do, is there something other than Macros I should be using to create a reusable way of handling something like a collision? I guess I could rely on the fallback value of “this” and then send events and receive them on other graphs, but that seems kind of hacky.
That is indeed correct. Most event nodes with a ‘target’, are designed to take the target either directly or via variables, because the node is initialized at the start (when the graph is initialized). That does indeed makes those type of event nodes not possible to use with a different target other than ‘self’ within Macros.
With that said, I could make the local Macro variables to be exposed in the inspector of the Macro node (in the parent graph), in such a way so that we could assign the ‘target’ there (within the inspector of the macro node in the parent graph). This is actually how sub-graphs work in in general in NodeCanvas and FlowCanvas, however within FlowCanvas Macros specifically, I disabled this feature for the shake of keeping things simpler since Macros also have their own inputs ports (even though for the use case of event nodes they don’t fit the case).
So for example this would look like this in the Macro itself:
And like this in the Macro node in the parent:
I’ve made some initial tests as you can see and it works fine. Just need to test this a bit more, but if you’d like I can send you the files for testing as well 🙂
Thanks for the reply and for taking the time to build out this feature! I actually ended up reworking how I handled this scenario in a way that doesn’t use Macros here so I’m not in immediate need of this functionality. But I think this would be a great addition and I’m looking forward to having it in the future.