Scope of dynamic variables

Forums 💬 NodeCanvas 🗨️ General Discussion Scope of dynamic variables

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15048
    etabubu
    Participant

      Hi,

      I’m wondering about how blackboard dynamic variables work exactly.
      I’m using them and everything “works”, but I notice some odd behavior sometimes and it might be related to the dynamicVars.
      My question is: what’s the scope of a dynamic var? Can there only be ONE at a specific time in a single BT?

      If I set and check a dynamic var in some node of the tree and then I do the same (with different values) in another node… am I overwriting the original one?

      Thx!

      #15050
      Gavalakis
      Keymaster

        Hey,

        The scope of the dynamic variables is just like all other variables. They are accesible from all nodes/tasks like any other blackboard variable is. The real difference is that they are created at runtime instead of pre-created.
        You can have as many as you want, but if you are setting a new dynamic variable and a variable with the same name and type already exist it will overwrite the old one. If not, a new one will be created.

        If you are checking a dynamic variable and one exists with same name and type you will get it’s value, if one doesn’t exist you will get the default value of the type of that variable.

        Hope this helps 🙂

        #15049
        etabubu
        Participant

          Yes, not it’s clear!

          Thank you!

          I love this tool! 🙂

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