(Unity 6000.0.28f1, Behavior 1.0.7)
When creating a new blackboard variable, you can pick some engine component types but not all of them. For instance, you can create a Box Collider 2D variable, but the Box Collider (the 3D one) isn’t there:
Some other components are also missing, such as Rigidbody. (Edit: Just noticed I can create a Rigidbody variable using the “New Rigidbody…” option in the “Link Variable” list, so this is a UI bug in the balckbord)
Why are some components present but not all of them? My hypothesis is that only the MonoBehaviour one are present, but not the Component one.
Also, when creating a custom Action, if I need a reference to a Rigidbody, creating a BlackboardVariable<Rigidbody> works well, but at the moment to link the field to a blackboard variable, I have to pick in a set of GameObject and other MonoBehaviour variables.
The problem I see is with this approch is that we are going to have lot of GameObject and other MonoBehaviour variables in the blackboard but only some of them have a rigidbody, leading to possible user error. It is possible to pick a GameObject that don’t have a Rigidbody:
I would have prefered to be able to create Rigidbody blackboard variables and only them can be assigned in the UI to a BlackboardVariable<Rigidbody>. If a developer wanted to allow graph designers more flexibility, they could use a BlackboardVariable<GameObject> and get the component from the GameObject in their custom actions code…
Why was it made like that, and is it possible to change this in the futur?
It looks like it’s an oversight from when I wrote the blackboard initially and I got used to MonoBehaviours so much that I forgot of the underlying Component
Lucky for us, all the serialization stuff is correctly done for Component so while we might need to update some UI code, we should be able to easily expose Components!
With this fix, do you also filter the “Link Variable” list to display only the assignable blackboard variables depending on the type? (the second part of my original message)
Unfortunately that’s not doable (unless I’m missing something). The reason being is that we allow you to cast types and we can’t actually test if your GameObject contains a certain component or not during authoring time. What we can (and should do) is add parenthesis on what’s the variable type and make sure it’s ordered so your explicit type is at the top.
Okey
I really like the idea to put the explicit type first!
I think it still possible to filter some of the variables:
In my screenshot, the action variable is of type BlackboardVariable<Rigidbody>. The list displays the New Mono A variable, which is of type MonoA (a MonoBehaviour script just made for testing that do nothing). It’s impossible to cast this variable to a Rigidbody as expected by the action. Furthermore, when I put my MonoA script on a GameObject that also carry a Rigidbody, the action still doesn’t get the link to the Rigidbody.
Given that, I think there is no reason to display New Mono A variable in the list. This can only result in user error/confusion.
Hey @Pitou22 , thanks for the response! Just to make sure, what do you mean “it’s impossible to cast MonoA to a RigidBody”? As it’s a MonoBehaviour, it should be able to do GetComponent which is what our ComponentToComponentBlackboardVariable does and what you should land in at runtime attached to your variable.
If you are assigning a MonoA that also has a RigidBody and you’re not getting your RigidBody at runtime then that’s a bug!
Can you please confirm? And if so, can you also show what type of object you end up linked to the “Apply Explosive Force” node at runtime?
I don’t know what I missed the first time I tried. This is why I don’t like too much flexibility, there are many way to do errors without noticing while setting up the scene and graph.