Not a Bug

Help referencing object as a variable

Federico Martinez 3 years ago updated 3 years ago 5

Hi Lazlo,

Im probably doing something wrong. Anyway I have this 2 custom events. I had them setup with FindGameObjectWithTag and that way they work fine but since this is for mobile I am trying to use the find object functions as least as possible so I wanted to create a reference I am guessing at start? and what's weird even with an initial variable not found error it works when I have only 1 flow pulling from that variable but if I have 2 flows pulling only 1 works:

this works

So I tried at start doing this:

and replacing those 2 findgameobjects with:

Whats strange is 1 works the other does not and the red one is the one that works... the blue one does not. even though both show as if the object is being passed correctly.

Should I do this another way? I also thought about having each object with a custom event trigger do a self scene variable at start but I don't want to many scene variables like that..

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by Federico Martinez 3 years ago
Pending Review

Hm, odd, it's as if your Jump event was called before Start. Can you debug log to make sure that this isn't happening?

yes the its like that because the error shows first but doing a debug log does not show that. 

The first error is a unity problem supposed to be fixed in 2017.3 I don't think its related.

Can you paste the stack trace of the InvalidOperationException please?

Not a Bug

Ok, I understand what's happening here.

When the graph gets initialized, before even Start gets called, it's trying to update the target for every event.

At that point, "control" hasn't been created, hence why the error.

This is "by-design": it's normal for events to determine their target before the graph starts working.

There are two solutions:

1. Create an empty graph variable called control in the inspector:


2. Enable fallback on the get variable unit, and fallback to null:

This works because Bolt will just ignore events with null targets.

ok just tried #1 and that works thanks!!