Proper way to initialize DynamicVars?

NodeCanvas Forums General Discussion Proper way to initialize DynamicVars?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #16573
    node tarp

    Hey guys.  I have a Behavior Tree that leverages a lot of values meant to be overridden at runtime. It all works at the moment, but when I start the game, I receive a bunch of logs saying No variable of name '[variableName] and type ‘[VariableType]exists on Blackboard '[GameObject Name]. Adding new instead…`.  This seems to imply that I’m skipping some sort of step to properly initialize my DynamicVars.

    If I simply add a DynamicVar (EG. _wanderSpeed) as a Graph Blackboard Variable at edit time, my code instead generates another instance of the variable and ignores the original one. This means that I don’t really have visibility into which DynamicVars my BehaviorTree will be using as I’m editing (I have to be extra careful to make sure the DynamicVars I type in are the same as what my code is going to set, versus being able to pick it from a dropdown), and that I have to basically set up a way to inject “default values” myself, since there doesn’t seem to be a way for me to set default values on DynamicVars on a per-BehaviorTree basis, since it seems to want to explicitly reference a Graph value or a GameObject value, but not let either override the other.

    I’m probably missing something yeah? If it helps at all, I’m generating my BehaviourTreeOwners and assigning their BehaviorTrees at runtime, so at edit-time none of these components exist.  If I’m basically as close as I can get already and the “Adding new instead…” logs are just letting me know things are working as intended, hopefully I can turn those off.



    Hello there,

    Are the two named dynamic variables (the one you add and the one created) exactly the same name AND type, as well as on the same blackboard (graph vs gameobject blackboard)? Furthermore is there a specific reason you opted to use dynamic vars (which as a convention they start with an underscore “_”, versus normal variables please?

    Let me know. Thanks!

    Join us on Discord:

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.