Sep 28th 2016
Implementing dialogue system based on data table in Unreal Engine 4 is not a difficult task because they have already implemented core functionality. What I have referenced is Implementing Data Driven Gameplay Although there are several issues which will prevent you from building efficient and flexible dialogue system, this method is quite simple and easy to follow The Dialogue system of ours is based on 3 core components. Phrase, Option, and Prerequisite. 1) Phrase - Phr_name : Name of this phrase - Script : A script that each phrase will show you - Prereq_Arr : A list of prerequisites that each phrase requires. If there is any prerequisite not satisfied yet, you can access neither phrase nor option that will lead you to this phrase - Gives_Arr : A list of prerequisites that each phrase will release. When you enter this phrase, it can let you see a certain phrase or option that will lead you to that phrase. - Optname_Arr : A list of option phrases. Each phrase can have maximum 4 options that will lead you to the next phrase. - Startprioirity : Starting point of the phrase. The higher the rank, the higher its priority is. 1 is the highest rank and 0 has no rank. You can consider this as an index of root node of phrase tree. - Delegate : A string that "calls a function" as its parsed by the system. It goes through switch statement and calls code based on it 2) Option - Opt_name : Name of this option - Script : A script that each option will show you. This is only can be seen from certain phrases. - Target_phraseindex : Index of phrase that option is targeting. When you choose this option, it will lead you to the phrase of this index. 3) Prerequisite - Index : Index of this prerequisite - Prereqs : List of prerequisite What I did - Composed 3 core structures - Find a way to parse data to Datatable asset Issues & Problems - Datatable row structure requires something it can identify each row. This is why I add Phr_name and Opt_name. - Datatable can't handle custom or nested structure. It cannot referencing or pointing other data from data it has. - Access by name only. Blueprint only allows us to access to the Datatable by drop down list selection. So you can't get certain Datatable by name or something else. This will lead you to unpleasant hard coding. - Datatalbe is a static, read-only asset because UE treats structure as just a datatype. Datatable's row structure is a structure type too. You can create Datatable asset from CSV file by using Excel or something, but to create it dynamically, you need some more extra works. - The reason I separated Phrase and Option is because UE does not allow us to create structure or class that holds pointer of same structure. It should have been something like linked list, but I don't know how to do that in Unreal. ex) struct MyStruct { int blah; OK float blahblah; OK MyStruct* pointer; NOT OK };
0 Comments
Leave a Reply. |
AuthorHyung Jun Park ArchivesCategories |