Paste this text into the "Add a New Format" section: https://www.maximumverbosity.net/twine/Entweedle/format.js
Step 2 of 2: Create a simple dialogue parser
Now that the twine data is in a clean format we can easily write a dialogue parser for Unity. I have included my solution below which includes two files. DialogueObject.cs defines the Node, Response, and Dialogue objects which use OOP to represent the story's text and links between nodes. DialogueController.cs defines methods to direct the dialogue system as your game runs, it also has a public event that your display classes can latch onto.
Dialogue Object.cs
Note: Entweedle changed their export format since writing this tutorial so please refer to this code for the parsing method:
Dialogue Controller.cs
Good Luck!
Now you can create your own user interface to show a branching narrative in your game. I thought it would be beneficial to show you my implementation for the game 22nd Street Traffick (playable here: mrventures.itch.io/22nd-street-traffick ) DialogueViewer.cs
9 Comments
8/22/2020 02:04:58 am
Hi I am Manaki. Working on a 2D Zelda like game.Your twine to unity tutorial was helpfull.I am currently trying to figure out how do I implement your code in my game because i am a noob and my head already hurts. well if i dont figure out by next week i might have to hit you up! But amazing tutorial very helpfull.
Reply
Matthew Ventures
8/22/2020 06:59:51 pm
Sure thing, try your best and email me if you need help via [email protected]
Reply
1/14/2021 08:25:53 pm
Hello! Love your work :)
Reply
Matthew Ventures
1/25/2021 09:31:16 am
It looked something like this: https://pastebin.com/sC4S3ghU
Reply
Amit Tank
8/3/2021 03:30:48 am
Can we merge 2 twine files?
Reply
Matthew Ventures
8/5/2021 04:57:33 pm
I have not done this but I looked on Google and saw that several tools do this:
Reply
Fabian Cham Sparr
3/20/2022 09:31:06 am
Hey, I copy pasted your two scripts and I got this: https://ibb.co/4JVs0qd . I'm not sure if I just copied it improperly. It's been very long since I've been programming at all.
Reply
Matthew Ventures
3/20/2022 10:25:10 am
Sorry unfortunately I'm not able to help everyone 1:1 with their coding. If you want a paid private session, I can dedicate time to working through your use case and teaching you how to code. Please email [email protected] and we can make it happen.
Reply
Leave a Reply. |