Saturday, May 10, 2014

Dialogue


The very first line ever uttered by Life Witch in the game.  Dialogue can speak volumes about the narrative, lore, characters, and their relationships.  But how to achieve this?  Depending on when and where dialogue may be used, the process can become quite complex and convoluted.

First, determine where will dialogue be used?

For Bala, at the beginning of a level, Life Witch will speak about what she knows of the location or some history, or whatever happens to pop into her head. She will also share some lines with the boss of the level before their fight, and some lines after their fight.  However, she will also comment on certain areas or objects in the level.  So the amount of dialogue she may have in any area can differ depending on how much we want her to talk.

So we know we need a dynamic way of triggering the dialogue.

In Bala, dialogue has been separated to be triggered in one of three ways: automatic trigger, activated trigger, and boss specific.

Automatic trigger is a trigger volume that will start up the dialogue when the Player walks into it.

Activated trigger is also a trigger volume, but will only start up the dialogue when the Player presses the interact button while inside the volume; it is very useful for signs and books or other objects the Player can examine.

Boss specific is reserved only for the boss fight sequences as there may be special effects that we want to play while the dialog is occurring.  It is also different in that this is one of the few times Life Witch will be talking with another character, instead of commentating, and the other character will have to appear on the other side of the screen.

With three ways of initiating dialog, we can can call it for almost any given situation. But how to proceed the conversation if there's more than one line?


That's okay Life Witch, here's how it works.

Let's look at the screen and break it up into it's components.  There are actually three cameras at work to composite the scene on the screen.  The main gameplay camera shows Life Witch in the world so we can get a sense of background.  Layered on top of that is a camera far off into the distance where only a closeup of Life Witch's model is seen and the background is culled.  On top of that is the third layer, containing the dialogue box and the dialog text.

Here's the hierarchy of how the dialogue box and texts are set up:


Note that we are using NGUI because it provides a nice base for us to work from has several tweening functions so we can slide objects in and out without having to write up extra scripts for them from scratch.

The dialogue box will always be the same, and we want the dialogue to always align within the box so it makes sense to parent them.  The Dialogue_InitialWakeup is just an empty gameObject used to store the lines for that one conversation.  (Also note the misspelling of dialog.  That happens when you just copy and paste without regard to naming).

In another area of the scene, there are several dialogue controllers.  Once the trigger initiates the dialogue, it turns on the appropriate dialogue controller, which controls the flow of the dialogue.


There are several variables here that lets the designer determine how the dialogue will play out.

"Will Remove Control From Player" does exactly that.  This is useful for dialogue at the beginning of the level or before and after the boss fight, where the Player should not be running off immediately.  This is also useful for cutscene events where the Player must pause while something else occurs in the scene.

Dialogue Lines refer to the parent gameObject that contain all of the lines for that conversation.

Left and Right Characters are the characters that will show up to the left and right side of the screen.  If there are none, then nothing will show up.  These characters must be within view of the proper camera, otherwise they will not be layered on top of the gameplay view.


Dialogue Box is the actual box background and is what will be pulled up when the dialogue begins.

"Is Automatic" refers to whether or not the player has to press a button to advance the text.  Some text will be automatic, such as when Life Witch makes random commentary on the levels.

Automatic Timer is only used when "Is Automatic" is true.  It determines how long a line of dialogue will play before advancing to the next line.

One variable not seen is the private Current Line.  This will always start at zero and will increment based on player input or automatically with the timer.

As for the actual logic behind the Dialogue Controller, to avoid long and boring specifics of what goes on under the hood, here is a brief overview:

1. When the dialogue controller is enabled, grab the characters and dialogue box and move them into place.  Also set the first line to active.

2. If this is automatic, start counting down on the automatic timer.  If it reaches zero, increment the current line, set the previous line to inactive and set the new current line to active.

3. If this is not automatic, when the Player presses a button, the current line is incremented, the previous line is set to inactive and the new current line is set to active.

4. Repeat for as many times as determined by the number of children gameObjects the parent dialog gameObject contains.

5. When all of the lines have been played, pull back the characters and dialogue, reset everything, and turn off the controller.

Despite the dialogue system being able to do this, it is still not quite done yet.  A planned feature for the activated trigger is to allow the Player to view the same dialogue repeatedly.  That way, if the Player misses information, they can refer back to it.  Another feature is to create a custom editor for dialogue controller to make it more designer friendly, such as hiding the Automatic Timer if it is unneeded and making Dialogue Box automatically assign itself.

A nice caveat of having the 3D models closeups is being able to have them animated.  For now, the amount of animation is limited, but eventually a system may be implemented to have them change poses or facial features to show more personality.

Also, rudimentary sounds/voice acting have been implemented.  Not everything spoken has a voice yet, but hopefully everything will by the end of the quarter, provided we have time and talent to spare. If not, the system is still in place to have that effect.

Overall, there have been plenty of progress, though there is plenty of room to grow as well.  Here's hoping to show even more polished work next time.

No comments:

Post a Comment