Search Unity

How to make dialogue system with stored data in xml

Discussion in 'Scripting' started by f2pallglory, Jan 12, 2019.

  1. f2pallglory

    f2pallglory

    Joined:
    Jan 11, 2019
    Posts:
    25
    Hello guys, sorry for my newb question :)

    i was trying to make a choice consequence dialogue inside my simple rpg, that means what choice the player made will affect the player status.

    but i am stuck on making the dialogue with choices.. what is the usual method used on this case? i was searching for a day and found about using xml to store dialogue data with node, then i try making the xml for dialogue like this :
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <Nodes>
    3.   <DialogueNode>
    4.     <NodeID>0 </NodeID>
    5.     <Text>Hello there, are you new here?</Text>
    6.     <Options>
    7.       <DialogueOptions>
    8.         <Text>Hi, yes my name is Dud</Text>
    9.         <DestinationNodeId>1</DestinationNodeId>
    10.       </DialogueOptions>
    11.       <DialogueOptions>
    12.         <Text>Ah.. yes</Text>
    13.         <DestinationNodeId>2</DestinationNodeId>
    14.       </DialogueOptions>
    15.     </Options>
    16.   </DialogueNode>
    17.   <DialogueNode>
    18.     <NodeID>1</NodeID>
    19.     <Text>Nice to meet you dud, i am Roxi </Text>
    20.     <Options>
    21.       <DialogueOptions>
    22.         <Text>Exit</Text>
    23.         <DestinationNodeId>-1</DestinationNodeId>
    24.       </DialogueOptions>
    25.      </Options>
    26.   </DialogueNode>
    27.   <DialogueNode>
    28.     <NodeID>2 </NodeID>
    29.     <Text>You look confused, what happen?</Text>
    30.     <Options>
    31.       <DialogueOptions>
    32.         <Text>Nothing..</Text>
    33.         <DestinationNodeId>-1</DestinationNodeId>
    34.       </DialogueOptions>
    35.       <DialogueOptions>
    36.         <Text>Actually.. i am searching for someone here</Text>
    37.         <DestinationNodeId>-1</DestinationNodeId>
    38.       </DialogueOptions>
    39.     </Options>
    40.   </DialogueNode>
    41.  
    42. </Nodes>
    43.  

    but i dont know how to process this, after i load the xml , how to load a desired node and how would the node player choose changed the player status, i was planning to make many npc and i find it hard to set every npc case of status effect (e.g : if i choose node 3 for npc1 it would be + status, but in npc3 it would be minus status in node 3).
    Would be happy if there is example for this, i am new to unity and would be glad to learn something new if needed for this.

    Thanks in advance
     
  2. If you're new to unity you shouldn't start with tackling a complex problem like this. Go step by step. Learn how to load up and XML, how to get an object-hierarchy out of it, how to save it back, how to display things from a tree, how to follow a path on a tree, how to build a dialog system from the UI point of view, how to develop UI to make choices, how to decide what choice will mean what in your gameplay and when you have done all of that, learn how to put it together.
    But for a beginner all of these problems will be complex and will spend considerable amount of time on them.
    If you want to do it yourself, my advice is start small, understand how to do the parts and then you can try to put together. Providing complex example for you (basically a done module) is useless. You can buy better solutions from the Asset Store and you won't understand the parts. So if you want to modify something, you won't be able to, because you won't be familiar with the deep mechanics.
     
  3. f2pallglory

    f2pallglory

    Joined:
    Jan 11, 2019
    Posts:
    25
    Yeah you are right, i need to learn the step by step needed for the complex problem first,
    actually i want to learn it by searching for example of the same problem but i found nothing anywhere ..
    and rather confused too if storing in xml is best way to do the dialogue system that i want
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    IMO, xml is a bit too complicated.