Note: this is a script to simulate speech using audio files containing syllables, using AC's text Scroll audio feature.

To use it replace the text in a .cs file named TextScrollRandomizer with this text, or create a new blank text file, then paste the text and rename the file TextScrollRandomizer.cs. Next attach it to any character you wish to affect, then, in the inspector, select all the audio files to be used by the effect. Also note that you need to ensure scrolling sound is enabled in the Speech Manager and that the character has a talking animation in the AC Player/NPC script (which is checked to verify if the character is speaking or not).

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
		void Update () 
			if (thisChar.isTalking)// change syllable only if the character is speaking -Alverik
				//Randomly choose a syllable and set it as the new textScrollClip audio file
			currentSyllable = Random.Range(0, syllables.Length);
			thisChar.textScrollClip = syllables[currentSyllable];

-Provided by user Jdag-

-Code slightly Edited by Alverik-

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.