[PATCH] when agent is null

Forums 💬 NodeCanvas ⚙️ Support [PATCH] when agent is null

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16113
    hosnkobf
    Participant

      Hi,

      I am up-using node canvas for our strategy game. The characters get different graphs assigned by code at certain events.

      sometimes characters are destroyed. Probably my code is buggy because it seems like destroyed characters sometimes also get a graph assigned. Then the agent is “null” and for some reason all newly assigned graphs for existing characters are stuck in the first node.

      I refactored my code a bit and maybe fixed the problem there (couldn’t reproduce it yet). But I also patched ActionTask.Execute() just to be more safe:

      I guess it would be a good idea to apply my patch to your repository.

      #16116
      Gavalakis
      Keymaster

        Hello,

        Hmm. Within this same method (Execute), there is this piece of code:

        The above code, is basically handling the agent null check but also initializes the agent. The reason this piece of code is not at the very top, is so that the checks and initialization only happen when the action is executed initially (and not every time while it is running).
        It seems however that in your case, the agent is destroyed while the action in question is Running or paused?
        Are you maybe destroying the agent from within an action task, or is destruction happening from some outside piece of code?

        Please let me know.
        Thank you.

        #16115
        hosnkobf
        Participant

          Hi,

          When I am destroying a character I call in OnDestroy() _currentActivityGraph?.Stop(); This should be enough to abort the graph, I guess.

          However, I got the null-ref-exception at OnUpdate() before your quoted check is executed:

          It was not clear how to reproduce it. So, I am not quiete sure what caused the graph to get there. If I find out more, I will let you know.

          #16114
          Gavalakis
          Keymaster

            Hello again and thanks for the follow up as well as the information.
            I will try to reproduce this and I make the required changes to avoid this null reference. (probably implementing your fix as well).
            Thank you 🙂

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