Subtree Node loses its reference after use.

NodeCanvas Forums General Discussion Subtree Node loses its reference after use.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #12232
    arachnidjacob
    Participant

    So noticed a strange behaviour with a nested subtree node.

    Steps:
    1: Switch a subtree node to another behaviourtree with a subtree node in play mode
    2: exit play mode
    3: inspect subtree node in the behaviourtree asset

    Result:
    The nested subtree node loses its reference to the behaviourtree that was in it, resulting in null after a single play mode.

    Is there a better way to switch Subtrees at runtime? Is there some command im missing when switching/unplaying?
    Any insight into this would help me greatly, thanks!

    Attachments:
    You must be logged in to view attached files.
    #12235
    arachnidjacob
    Participant

    I should be clear, the subTreeNode that is losing its reference is NOT the subTreeNode that i change, but the subTreeNode is inside one of the behaviourtrees that is put into the subTreeNode

    #12250
    Gavalakis
    Keymaster

    Hello,
    Thanks for reporting this. I was able to reproduce this problem. This appears to be happening when you swap the target SubTree reference when the SubTree Node in which you swap the reference is already *Running*.
    I will of course need to fix that and add a failsafe check, but please avoid swapping the target SubTree reference (either manually or through variables) *while it is Running*, because it will result in unintended behavior until I fix this.

    Thanks again for the report.

    Join us on Discord: https://discord.gg/97q2Rjh

    #12273
    arachnidjacob
    Participant

    Is there a good way for me to swap trees at runtime, like temporarily stopping the node while a swap is ocurring? maybe multiple branches that can Queue trees dynamically?

    #12274
    arachnidjacob
    Participant

    Also, there is one tree where this does not happen at all, but it has its tree referenced in a blackboard variable.

    #12280
    Gavalakis
    Keymaster

    Hello,
    Sorry for the late reply.
    You can stop the behaviour tree (owner) before switching the target graph if you do have to do it manually in the editor while the game is running. Otherwise, you can of course use blackboard variables to switch the trees in runtime, which is how trees are intended to be switched in runtime if required.

    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #12284
    arachnidjacob
    Participant

    Hi Gavalakis, i appreciate the time and effort you are putting into keeping the forums going and answering questions, so dont worry!

    Ill try to explain my process as best i can and you can tell me if i am doing something wrong with my approach, or if i should abandon the design entirely and try to re-think the way i’m doing things.

    Reactions and actions, i switch out the Mission Subnode tree depending on reactions which causes the tree to lose its reference even if its in the BB.
    treeTrunk

    I add the reactions at start from the chosen AI profile
    blackboard-and-reactions-in-it

    This is the designer interface, when creating a new AI profile (Captain), you match missions to two sets of flag enums for who is doing the action, and what action it is.
    Captain-Reactions

    I tried stopping the tree before switching, Which stopped the references from dissapearing like you said, but it causes a 1 frame infinite loop error on the AI trunk start node that i’ve not been able to circumvent.
    stopStart-annotated

    Attachments:
    You must be logged in to view attached files.
    #12290
    Gavalakis
    Keymaster

    Hello agin,

    Thanks for the follow up and for the further explanation.

    I have made some quick changes to the SubTree node (attached for you here) and now changing the target SubTree, even while the SubTree node is running -both in editor or in runtime- should work better (no reference lost and no need to stop/restart).
    Please note though, that if the change happens while the SubTree node is running, the actual change will take place only once after the previous target SubTree is finished first (return anything other than Running).

    Can you please test it out and let me know how it works for you?

    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #12292
    arachnidjacob
    Participant

    Yes this works!
    I dont seem to be losing the references anymore, this frees up the way im able to design around BT’s as specific responses to situations.

    Thank you!

    #12311
    Gavalakis
    Keymaster

    You are very welcome 🙂
    Thanks for letting me know.

    Join us on Discord: https://discord.gg/97q2Rjh

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