Getting an InvalidOperationException when passing a List to a super unit

gdasd2 1 year ago updated 1 year ago 6


I have a macro to control a pressure plate in my game. I maintain a List with all current colliders so I can trigger custom events when the collider count is decrased to 0 (deactivate event) or when the collider count is increased to >= 1 (activate event).

I capsuled the logic for all the collider checks to a dedicated super unit:

Inside this super unit I call some List functions to perform all the collider validations. I get the following error when calling Contains():

NullReferenceException: Object reference not set to an instance of an object

And I get the following error when calling Remove():

InvalidOperationException: The value of 'listOutput' on 'RemoveListItem#a2da3...' cannot be fetched dynamically, it must be assigned.

The List is an object variable. I access the variable on my main macro via the "Get Variable" node and pass it to the entry point of my super unit. Can you tell me what my problem is?

Thanks in advance!

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

Hi gdasd2!

So it sounds like you created a connection between the output list of Remove List Item and something else.

However, you did not connect the control flow for Remove List Item, so the unit is not entered before you try to get the result.

That is what the "cannot be fetched dynamically" error means.

Can you paste a screenshot of the graph with the erroring (red) node so I can guide you to fix it?

Hi Lazlo,

Thank you so much for your answer. I checked again what you said, but that doesn't seem to be the problem. However, I noticed something. In the screenshot below you can see the Super Unit I created to add or remove the colliders to the list. At the beginning of the game the list is always empty. Then a collider is added (via OnCollisionEnter). This works quite well so far. But if OnCollisionExit is triggered, it runs through the lower (blue) part of the flow graph (which is correct), but returns the list of the upper (red) part "Remember / Add to List logic" instead of the list that I have linked. So the flow is correct, but it returns the wrong list. It also explains why there is a problem with the returned list of AddItem. It tries to return the result of AddList. But when performing the "Forget"-logic the function AddItem is never called.

Is it a problem that I have so many different output nodes? I hope my problem is understandable. Many thanks in advance!

If I may add. If the forget logic is run through, it looks like this. Flow is green, the list that is returned is purple and the list that is supposed to be returned is not used.


Hi gdasd2,

Indeed, as you can see from the yellow node color and the warning in the graph inspector, multiple output nodes are not supported.

I recommend using a Select On Flow unit to "merge" your flows and return the proper list in a single output unit.

Thank you so much, it's working now. Now I feel dumb for not seeing this obvious error :-D