-
Notifications
You must be signed in to change notification settings - Fork 7
Dialogue
I try to create a simple but flexible dialogue system. Here how it working
-
NpcInteractioncontrol player behavior and manage communication with the NPC -
NPCwill communicate withDialogueController -
DialogueControllerwill everything about the dialogue of the NPC- Load and search JSON file
- Preload all portraits in memory
- Communicate with the
DialogueBoxscene
-
DialogueBoxis the dialogue UI, it will manage- Choices
- Scrolling
- Communicate with
DialogueControllerabout his own state

I create a small tool to manage all my JSON dialogue files. You should use it to save time. You can download it right here and get the source code here (it also has its own wiki)
JSON file should be placed inside res://assets/dialogues/ and should share the same name of the NPC's node name.
e.g. Jack will use Jack.json, JackLevel2 will use JackLevel2.json file. Of course, you can edit it, I through it was pretty useful for my workflow.
I will just redirect you to LE Dialogue Editor's wiki
If you are not used to json we are limited to the number of types. Type like Vector and Node doesn't exist in JSON. The way I overcome this issue is by
- Signal without parameter are set with a
nullvalue - Signal with parameter are set as
Dictionaryin the shape oftype=>value
"signals": {
"npc_script_event_started": null,
"notification_started": {
"String": "dialogue generate event"
},
"camera_offset_changed": {
"Vector2": {
"x": 200,
"y": -400
}
}
},Doing that way, I let me translate the key to a real Godot supported type.
func _convert_value_to_type(type: String, value):
match type:
"Vector2":
return Vector2(value["x"], value["y"])
return valueCan display a non-player controlled dialogue that will terminate itself after timer's value, he used for one unique dialogue. Value is in second.
Will not use the next value, can only show one dialogue at a time
"001": {
"name": "Player",
"portrait": "Player",
"text": {
"en": "I can now double jump",
"fr": "Je peux maintenant sauter une deuxieme fois"
},
"timer": 5
}