Documentation

Learn how to use NodeCanvas

BBParameters

In most places where you are able to set a parameter in NodeCanvas, like for example within Tasks or Nodes, you will encounter what they are called BBParameters. BBParameters allow you instead of setting the parameter value directly, to rather link that parameter to a Blackboard variable, either of the same type or even of an “assignable” type due to the AutoConvert feature (see later in this section).

This is done by clicking on the radio button on the right side of the parameter and a dropdown list will appear.

There are four possible choices you can have within the variable selection dropdown:

  • Select a Blackboard variable to link the parameter to. This is the most obvious option.
  • Select a Global Blackboard variable if you have a global blackboard in your scene.
  • Declare a “Dynamic Variable” which allows you to create a variable at runtime.
  • “Create a New” Blackboard variable and link it to this parameter in one go (the created variable will have the same name as the parameter, but you can change that name later on without any problems).

When you have selected a variable this way you will notice that the information written for that task within the node UI related to that variable, will come with an “$” token in front of the name of the variable. This is always added to indicate that this name refers to a variable and thus not to be confused with it just being a string for example.

AutoConvert

The AutoConvert feature in NodeCanvas allows you to link a BBParameter to a Variable that is not of the exact same type, but can rather be of any type able to somehow be converted to the BBParameter type. So for example the most obvious conversions would be linking a float BBParameter to an integer Variable, or a string BBParameter to pretty much anything. However there are more possible convenience conversions, like for example GameObject type to any Component type, or even GameObject type to Vector3 (through transform.position). Whenever such a conversion is taking place, it is shown in the UI right below the BBParameter inspector.

Notice that in the above example, the conversion is marked as “[GET ONLY]”. That means that while a conversion from GameObject to Vector3 exists and the above task will work fine, a conversion from Vector3 back to GameObject does not exist. This restriction is only really relevant for tasks that save data back to the Blackboard variable though.

In practice, if you can select a variable in the parameter dropdown, it will work and you have nothing more to worry about!

Here are some of the conversions that the AutoConvert feature supports and how they are done (this list might be out of date since more are added):

 

From To Through
Any IConvertible Any IConvertible .ChangeType
GameObject Any Component .GetComponent
GameObject / Component Transform .transform
GameObject / Component An Interface .GetComponent
Component GameObject .gameObject
GameObject / Component Vector3 .transform.position
GameObject / Component Quaternion .transform.rotation
Quaternion Vector3 .eulerAngles
Vector3 Quaternion .Euler
Vector2 Vector3 casting
Vector3 Vector2 casting
Anything string .ToString

 

You can also append your own custom conversions via code but this is a more advanced topic for later on.

Yes No Suggest edit
Suggest Edit

© Paradox Notion 2014-2024. All rights reserved.