Forum rules - please read before posting.

Randomize subtitle-scrolling audio sound effect?

Hey again!

I'm trying to do a specific style of voice lines, where each character randomly chooses from a small list of syllables every time they talk.  Here's an example of the same effect in Chibi-Robo:

(cut to 1:58 for a good example, if the time stamp isn't jumping there automatically for you!)

As the text scrolls, characters speak from a random list of syllables.  It's a fun way of adding voice acting for tone without actually voice acting your characters.

I know you can define a unique text scroll audio asset for each character, but that seems more geared toward games like Undertale, where characters are repeating the same tone over and over.

I've been looking into it for a while and I can't find a way to choose from a random list of syllables in Adventure Creator (please correct me if I'm wrong!).  If it's not currently possible, could this be added?

-John

Comments

  • It's true that the provided "scroll audio" feature only allows for one sound, but with some custom scripting you can add your own effect quite easily.  You will need to know some C#, however.

    While you can look to the Unity forums for some advice on how to write a script that plays a random sequence of AudioClips, you can hook this script into AC by using custom events.

    The custom event system provides you with "hooks" that basically let you call your own code when common AC tasks get run.  These tasks include the starting and stopping of speech - which you can use to start and stop your own audio-playback code.

    Here is a tutorial on writing custom events - which fortunately also makes use of the OnStartSpeech event that you'll need.  The other event you'll need is OnStopSpeech
  • That's close to what I'm looking for, but not quite right!  After a lot of experimenting, I've discovered that OnStopSpeech (and OnEndSpeechScroll!) behave pretty inconsistently.  They only seem to activate at the end of a full dialogue box, which is no good, because I have "Treat carriage returns as separate speech lines" checked in the speech manager.  I want characters to stop talking the moment new text stops being written, but those new speech lines aren't considered the end of dialogue, so they just keep going!

    I'm pretty sure this is just a bug in the system but it's very frustrating to try to find a work around.  Hoping you patch it so carriage return based speech lines count as stopping speech!
  • edited July 2016
    Okay, I made a pretty simple script to get what I was looking for.

    using UnityEngine;
    using System.Collections;
    using AC;

    public class TextScrollRandomizer : MonoBehaviour {

        //This script randomly changes what a character's textScrollClip sound is once an update.  Place it on a character.
        //With this, you can get that effect in games like Chibi-Robo where characters speak from a small list of syllables.

        //This is your array of syllables- plug them in manually in the editor
        public AudioClip[] syllables;

        private int currentSyllable = 0;
        AC.Char thisChar;

    void Start () {
            thisChar = GetComponent<Char>();
            if (syllables.Length < 1)
            {
                //Destroys this script if there's nothing in the syllables array, to prevent errors
                Destroy(this);
            }
    }
    void Update () {
            //Randomly choose a syllable and set it as the new textScrollClip audio file
            currentSyllable = Random.Range(0, syllables.Length);
            thisChar.textScrollClip = syllables[currentSyllable];
    }
    }

    It took me a while to get this just because this seemed like a pretty sub-optimal way to do it, but it works just fine!

    Like I said, OnStopSpeech/OnEndSpeechScroll don't end until a character is totally done talking, so I couldn't use those.  After devising some other workarounds, I ended up just changing the textScrollClip on the character directly.

    (Still pushing that this be added as a regular feature!  I bet other people would like this option too.)
  • Nice, I'll probably be trying this code sometime this year. If you are unable to get voice actors, this is a really good replacement. And in many cases, it can be a great artistic tool. I'd be thrilled If I can manage something just a little close to the type of "voices" they used in Okami, which is a similar technique and sounded great. Anyways, cool stuff.
  • I will have a look into it.  Know that you can also check if a character is playing their talk animation by reading their isTalking variable - this may be another approach you can take in the meantime.
  • edited August 2016
    Jdag, as I mentioned in my message, I posted your script in the AC Wikia, but I did a minor edit to it in the Update() function to make sure the randomization only occurs if the character is actually speaking (by way of the isTalking state of the talk animation, as Chris mentioned). I'm currently engaged into coding some features for my current project so I don't have much time to test it throughly, and seeing as you are already using it, would it be okay to test if it works fine in your setup? (that is, if you didn't already do the same edit yourself).
  • Whoops, only just saw your post, Alverik!

    I just tested it and your change works perfectly.  Definitely a smart choice to save memory. :)
  • Cool, that's great to hear!

    Anyway, happy developing!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.