Σελίδες

Παρασκευή 2 Φεβρουαρίου 2018

DevBlog update: I started building the Dialogue System of my game, with the help of Fungus!

An essential part of every RPG is a Dialogue System, that helps the player have conversations with various NPCs. As the development of my yet unnamed Action RPG continues to progress, in this early pre-Alpha stage it was about time for me to start implementing the Dialogue System. This system will be responsible for managing dialogues.

Trying out the Dialogue System, with Fungus.
Early prototype-phase screenshot with the use of placeholder 
graphics, from a testing area that won't be in the final game.

I decided to use Fungus to help me build the system for this game faster. Fungus is a cool and straight-forward system, a plugin for Unity, that its creators decided to share it with everyone, for which I'm grateful! Plus it's Free Software, so anybody can use it and expand on it. The Free Software Community has been very helpful. I already use tools such as Blender, MakeHuman, and now Fungus, for the development of my game, all great tools and free.

So how do I get the system to work as I want in my game ? First of all I had to find a way to let the code know which objects in the game have the ability to initiate a dialogue and which not. The first thing that comes to mind is NPCs, but that's not all of it. There might be inscriptions that the player has to read, for example. And not only the code needs to know which gameObjects can initiate a dialogue, but also which dialogue, and when. For example trying to talk to a certain NPC at a specific point in time should initiate a certain dialogue, but at another point some other dialogue. So one thing was clear from the very beginning: Each NPC had to have a component that decides which is the current dialogue for that given NPC, that will be displayed if the player talks to that NPC at a given time. As this can vary greatly from one NPC to another, I decided that there will be custom scripts that act like that for each NPC. But that wouldn't be enough. Because each such component will have to share something common, to let the game know that the gameObject that it is attached to can initiate a dialogue. So I created an interface for that purpose, that all such custom scripts will inherit.

Whenever the player hits the "Interact" key, there is a number of checks that run. The code checks if the player is looking at an item, an interactable object like a lever, and from now and on if the player is looking at a gameObject that carries a component that inherits the interface I mentioned earlier. So if the player is looking at a NPC that has something to say, the code then checks if the NPC is dead or alive, and if alive it checks a public variable, that contains a pointer to a Flowchart component. That Flowchart component is the current dialogue for that NPC. The code that runs at FixedUpdate() determines which is the current dialogue for each moment the player presses the "Interact" key on the keyboard. So once the Flowchart that should start execution is known, the code does just that. But how does the execution of the Flowchart starts ? Well by the call of the method 

Flowchart.ExecuteBlock(string blockName)


As for the arg, I pass "Start", as I intend to name each starting block of a flowchart with that name. But still there is much work to do on the dialogue system before moving on. After I've figured out and tested the whole design of the Dialogue System, I will then move forward and focus on humanoid character animation, to see how I can turn those MakeHuman 3D models alive.

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου