How to access Dynamic Variables in code?

Forums 💬 NodeCanvas ⚙️ Support How to access Dynamic Variables in code?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #17079
    test84
    Participant

      Hi,

      In Check Trigger 2D action, I store the GameObject of a bullet that hit a character so in next state it can face the bullet. I’m using Dynamic Variable as it’s a temporary thing but I can’t find how to retrieve info from it in the next state for the life of me!

      To clarify, I need to access my Dynamic Variable from a Check Trigger 2D in the next state I’m transitioning to via my own custom Actions.

      p.s. I have a lot of problem accessing the website today, almost always it fails to load.

      Thanks

      #17087
      test84
      Participant

        Apparently I can do it via blackboard.GetVariable<T>("myDynamicVariableName") , wish there was an example in the documentation about it. Please correct me if I’m wrong in terms of either this is a good use case for using Dynamic Varibles and/or how to access it.

        When that line of code is executed, NC says it promoted the Dynamic Variable to a Variable in Blackboard, why is it?

        Thanks

        #17086
        test84
        Participant

          I can’t still access that variable, I tried the following:
          blackboard.GetVariable<GameObject>("_LastBulletThatHitMe").value
          blackboard.GetVariable<GameObject>("_LastBulletThatHitMe")

          but it’s always null.

          Sorry for spamming, I’ve been trying to do this by myself for past few days and I ran out of time.

          #17085
          test84
          Participant

            I can see my game object getting stored in saveGameObjectAs but something happens to it that it gets null.

            #17084
            test84
            Participant

              Solved my problem, it was due to another task that was delaying before this one.

              #17083
              Gavalakis
              Keymaster

                Hello,

                I am sorry that I wasn’t able to reply sooner that you’ve found the cause, but I am glad that you’ve found the cause after all 🙂
                If you have any other questions or problems, please let me know.

                Thank you.

                #17082
                test84
                Participant

                  It’s fine, thanks. Maybe I should’ve emailed you.

                  I think the most important missing piece from your documentation is code examples. I assume[d] your main audience are coders but your docs are mainly demonstrate using the editor and since I’m mostly trying to incorporate NC into my game via code (making tasks/actions), I usually find what I want in the docs but it does not provide code examples as well. Like dynamic variables and more recently global blackboards. I got global blackboards to work but I’m not sure if it’s the right way to do it (since I see a lot of template code behind the scene and it scares me a bit as I have to release soon and don’t have time to test much).

                  I’m hoping to provide these helps for the docs (via google doc’s commenting I think is best) but I have to learn them myself first.

                  #17081
                  test84
                  Participant

                    I also don’t get email notifications for topic replies.

                    #17080
                    Gavalakis
                    Keymaster

                      Hello again,

                      While there are some documentation sections that explain how to make custom tasks or use blackboard variables through code for example, can you pleae let me know what kind of coding examples you would like to see in the docs on top of those?

                      Thank you.

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