Adventure Creator Wikia
Advertisement

Here is way to Adjust how fast a Characters Text scrolls with a Speech Event Token in the Dialogue action.

Text Speed

First you will need to attach this Script to your Game Engine Prefab:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;

public class SpeechTokenMonitor : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnEnable()
    {
        KickStarter.dialog.SpeechEventTokenKeys = new string[1] { "textspeed" };
        EventManager.OnSpeechToken += OnSpeechToken;
    }
    private void OnDisable()
    {
        EventManager.OnSpeechToken -= OnSpeechToken;
    }
    private void OnSpeechToken(AC.Char speakingCharacter, int lineID,
    string tokenKey, string tokenValue)
    {
         if (tokenKey != "textspeed") return;
        // Try to parse the tokenValue string to a float
        if (float.TryParse(tokenValue, out float parsedValue))
        {
            AC.KickStarter.speechManager.textScrollSpeed = parsedValue;
            Debug.Log(speakingCharacter + " said token [" + tokenKey + ":" + parsedValue + "]");
        }
        else
        {
            Debug.LogError("Failed to parse token value as float: " + tokenValue);
        }
    }

}

This Script allows the Speech event Token "textspeed"

So if you want to now change a characters Text scroll speed, it would look like this:

"[textspeed:50]these chars will be printed with 50 speed. [textspeed:100] these chars will be printed with 100 speed"

Screenshot 2023-09-21 160346

Be aware however that changing the scroll speed caries over to edit mode, so you may want to attach this additional script to the subtitles UI prefab, or any UI element that is using text scrolling. This Script resets the Scroll speed to your default (Delineated in the int field of this script)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;

public class TextScrollDefaults : MonoBehaviour
{
    public float TextScrollSpeed = 90;
    // Start is called before the first frame update
    void Start()
    {
        
    }
    private void OnEnable()
    {
        AC.KickStarter.speechManager.textScrollSpeed = TextScrollSpeed;
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}

Hope this Helps!

Advertisement