How do I dynamically load dialog trees from prefabs?

Forums πŸ’¬ NodeCanvas πŸ—¨οΈ General Discussion How do I dynamically load dialog trees from prefabs?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13453
    toreth
    Participant

      I’m new to NodeCanvas and I’m trying to figure out how to dynamically load Dialogue Trees into Finite State Machine actions.Β  The Dialogue Tree documentation shows an example of adding the Dialogue Tree as a game object in the scene.Β  I did that, and the dialog works.Β  However, I want to be able to create prefabs for each Dialogue Tree, and have the “Start Dialogue” action of my FSM dynamically load the Dialogue Tree.

      I thought about putting a DialogueTreeController variable on my actor’s blackboard and then dynamically assigning that value in another action, but when I try to load my Dialogue Tree prefab using the code below, LoadAssetAtPath returns null, even though the path exists.

      Β var assetPaths = AssetDatabase.FindAssets(“My Dialog”);

      var dialogTreeController = AssetDatabase.LoadAssetAtPath<GameObject>(assetPaths[0]);

      What’s the correct way to go about dynamically loading dialog trees from prefabs?Β  I don’t want to write a bunch of code to reinvent something which probably already exists.

      #13456
      Gavalakis
      Keymaster

        Hello and welcome πŸ™‚

        Hmm. I have just modified the “Start Dialogue” action with an option “Is Prefab”.

        When that option is enable, the assigned DialoggueTreeController will be automatically instantiated and will also automatically be destroyed when the Dialogue is finished.

        I have attached the modified action for you here to test it out.

        Let me know if that works for you.

        Thanks πŸ™‚

        #13455
        toreth
        Participant

          That works perfectly.Β  Thanks so much for making that change.

          #13454
          Gavalakis
          Keymaster

            You are very welcome πŸ™‚
            Thanks for letting me know. This change will exist in the next version update by the way πŸ™‚

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