Assigning variable value in Blackboard asset problem

I reported this issue before. After then, it worked, so I was working on the next task, but the same problem occurred again.

Some images cannot be uploaded.

Anyway, the problem is that the above script frequently doesn’t get the reference.
The Agent variable of Blackboard asset is exposed and shared.

Hi @MOBILIN ,

Can you confirm if it’s the Self that’s value is null, or is it the Self not having the T4GNpcAgent for some reason?

I checked and it is being referenced normally.
Just in case, I exposed Self and assigned it as shown in the image.

In addition, the Behavior Agent and the custom component are in the same GameObject.

If you put a breakpoint in the OnStart, is the Self value assigned correctly and the T4NpcAgent is retrieved from it when you call GetComponent?

Did you try the Set Blackboard Value node?

Would you be open to having a zoom call to share your screen so we can see what’s going on?

like this?

Mostly! Does it not let you assign the Self to it directly without having to create a new variable? But yes, that can also work.

As shown in the image, Set Variable is normally assigning the exposed reference to the Variable of the Blackboard asset. However, GetComponent() through Self does not work as in the class I created.

  • This log came from my script.
    image

Hi @MOBILIN,

Is it correct in saying that the Self.Value.GetComponent() is failing and returning null even though the component should be on the Self object?

Can you show where the TGGNpcAgent component is attached on the NpcAgent@James (Self object) in the hierarchy?

If you look at the image below, it worked normally now.
I quit play mode and tried again, but it failed again…

However, box number 2 appeared. It’s the first time that I see this kind of message.
Anyway, I don’t know why box number 2 appeared, and I don’t know what it means.

It definitely looks like a bug of some sort, although it’s hard to exactly pinpoint the issue.

Can you try re-creating your graph to see if the issue persists?

It would also be great if you could file a bug report with the repo project, this way we could take a look around ourselves.

There are some known issues here & it could be that you have hit one of these problems.
https://docs.unity3d.com/Packages/com.unity.behavior@1.0/manual/troubleshoot.html#default-value-for-sharedblackboardvariable-variable-is-null

  1. It worked just once with new graph.

  2. I stopped play mode and restarted, then it failed again.

with this Blackboard:

I have never done a Unity bug report before, but this is my first time trying it.
However, it took a very long time to prepare for submission, so I cancelled it.

My project size is very large.
Does the bug report window compress my entire project and submit it?

If you could make a small new repo project replicating this case it would be best due to size,

Can you try making the variable not shared for now inside the blackboard as a test also?

We already checked it. It works with embedded Blackboard.

1 Like

To create a small project you could try creating a minimal repo scene & using the export package function.

This should hopefully only export the required objects used by the scene for the package which should be a small amount.

Hello @MOBILIN

I am really sorry for the inconvenience you are experiencing,

This sounds to me like a bug related to SharedBlackboardVariable (the one posted by Darren).
Could you try the workaround provided in the documentation?

This behavior might be editor only and not happen in a player build. Could you make a quick player build (using the first package sample scene and updating the graph to have your repro).

Even if that could solve the issue at runtime, this is a high user pain and we will investigate asap.

Really sorry for the inconvenience :bowing_man:

Will come back to you as soon as we have more info

I have not tried it yet because I don’t think this issue is related with Subgraph.
In addition, I did not use RunSubGraph node and I made a new graph so…