Godot Dialogue Graph with Json.
This is a simple Dialogue System for your Godot 3.x and 4.x games.
It is built around a preset JSON format ( Example found under Dialogues folder) .
I made this system for one of my pet projects and figured I would post it for anyone in need of a simple system or a reference for building their own.
For a more full fledged solution please check out this Open Source project posted here .
Show full description...
Description:
What you CAN do:
- Linear Dialogue
- Branching Dialogue (Multi-answer supported!)
- Looping and branching Dialogue
- Basically any kind of graph based dialogue
What you CAN NOT do:
- Dialogue Conditionals are at this point not supported and since I do not need them for my current projects it is unlikely i will be implementing it soon
How To:
---------- VERSION 4.0.2 + RECOMENDED ------------
Provide better naming for variables functions and files where applicable
Move all scripts to snake_case to match gdscript.
Split dialogue_manager from trigger:
The only demonstration on how to call a dialogue externally (from another node or user action) was inside the main dialogue_manager script , convoluting things in the script, possibly making it harder to understand and with no real way to show users how to do this properly.
Since then a second script has been added (dialogue_trigger_demo.gd) that shows how to interact with a dialogue system from any game or system easily. Along with this change the whole dialogue ui scene has been loaded as an autoload, making it readily accessible and minimizing resource use.
I suggest everyone go read the dialogue_manager.gd script in order to understand how the system works, and then check out the dialogue_trigger_demo.gd script on how to call it.
For anyone that has no previous experience with autoload scenes and scripts I suggest the official docs here.
The project has the dialogue ui scene already set up as an autoload, you will find it at Project > Project Settings > Autoload .
All in all this version should both be more readable, easy to integrate and use, and be a better educational piece than before.
For users Upgrading: Take extra note to check the changes in the demo json file, some renames have been applied to better match case sensitivity with the rest of the project, also the force option has been removed since it's now obsolete (due to trigger demostration).
-------VERSION 4.0.1 or older --------
There are instructions of how to Load a dialogue and start it inside the single script of the project (Scripts/DIalogueManager.gd) , if that is not sufficient feel free to contact me.
There is a Dialogue json Example that you ABSOLUTELY SHOULD look at. That is how your dialogue files should look like.
THINGS TO NOTE :
- Dialogue Nodes should start at id 0
- If you want to exit the dialogue set the next_id to -1
-Every Dialogue Node must have a different id number
-The generic next_id will be ignored if you fill the choices[] array.
- Currently supports up to 4 choices, you can easily expand it to more
FAQ:
Q: JSON Files are not showing in my Godot editor :
A: This is by Godot's design and is unlikely to change, you are still able to load and read the files just fine, they are just not shown inside the editor.
Godot 4 Update: You should be able to see json files inside the editor.
Hope you find this useful , looking forward to some feedback.
VERSIONS:
- 1.0.0 Original version as uploaded on 11/03/2018
- 1.0.1 Bug Fix As pointed out by user @Hobofairy
- 1.0.2 Port to Godot 4 (not backwards compatible with Godot 3).
- 3.0.1 renamed from 1.0.1 to reflect godot version
- 4.0.1 renamed to 1.0.2 to reflect godot version
- 4.0.2 clean up variable names, simplify dialogue manager script further, add extra comments. Move to a trigger - autoload solution (more info in description).
Tested And working with (should work with everything above 3.1) :
Godot 3 : 3.1 up to 3.6 (dialogue versions 1.0.0, 1.0.1, 3.0.1)
Godot 4: 4.0 , 4.1.1 (dialogue versions 1.0.2, 4.0.1, 4.0.2)