Shared Variable value is null inside Task? [Pro]

goidelify

New member
1749139536984.png

As you can tell, the variable EnemySelf is not null in the inspector, however when I try to access it via a variable is assigned with its value it only fetches null?

1749139660931.png1749139624000.png


That is, self.Value is null in the task. No matter where and how I assign it.
 
Hi, by any chance is your Behavior Tree component part of a prefab ? If yes try reverting changes applied to the component and drag the enemy in this slot again to see if it changes anything, or if it's not a prefab just try setting it to none and then assigning it again. If that doesn't change anything, could you confirm that self.Value is null by checking for it precisely (without Object.IsValid) using some simple if statement and debug log line ?
 
Hi, by any chance is your Behavior Tree component part of a prefab ? If yes try reverting changes applied to the component and drag the enemy in this slot again to see if it changes anything, or if it's not a prefab just try setting it to none and then assigning it again. If that doesn't change anything, could you confirm that self.Value is null by checking for it precisely (without Object.IsValid) using some simple if statement and debug log line ?
It is indeed on a prefab. I did some further debugging to verify that the issue I had was the one stated:
1749159511953.png
 
The prefab is the issue. Prefabs are project-level assets which mean they cannot reference scene-level objects. This is a restriction in Unity and to get around it you need to assign the object at runtime after the prefab has been spawned.
 
The prefab is the issue. Prefabs are project-level assets which mean they cannot reference scene-level objects. This is a restriction in Unity and to get around it you need to assign the object at runtime after the prefab has been spawned.
The issue is that even if I DO assign it after spawn (which is what I do by default already), it still doesn't replicate to the Tasks. Is this expected when working with prefabs?

My point being, this setup worked completely fine with Behavior Designer, but moving into Pro it fell apart and I could no longer set share variable values from scripts and have them replicate in the Tasks.
 
I just tried to reproduce this by both having a prefab instance within the scene and then also spawning the prefab and then assigning the variable value. In both cases it worked. If this scene doesn't work for you it could be related to this post and will be released soon.
 

Attachments

Back
Top