Set Field action returns Success, but BB variables are not assigned to the requested fields.
Example scene with only two 3D spheres:
sourceSphere has a bound behaviour tree and a blackboard that contains variable myGameObject == sourceSphere
targetSphere has a C# script component with a public GameObject variable “target”.
SourceSphere’s BT has only a single node and action: Set Field, configured as targetSphere.target=$myGameObject from the UI menus which allow the user to set the target’s transform, variable and value.
End result: BT returns success, but targetSphere.target remains null.
If I drag ‘n drop sourceSphere from the scene hierarchy into Set Field’s Set Value slot directly, the BT behaves as expected, targetSphere.target gets sourceSphere assigned to it.
In addition, the UI behaviour for Set Field is inconsistent:
– When the Set Field action is first created, targetSphere can be assigned as the transform, the public variable selected from a drop-down list, and myGameObject selected as a blackboard value.
– After pressing Play and then stopping the editor build, the BT changes behaviour, and Set Field’s pull-down menu no longer displays myGameObject as a valid variable for the slot, instead only listing NONE and (DynamicVar) as the available options.
You are very correct here. It’s a bug. Although It’s 2 lines change, here is the whole code.
Please open up SetField.cs and replace the whole code with this: