Page 1 of 1

Questions about implementing the effects of shaking the Subtitle Text

Posted: Wed Feb 26, 2025 2:23 pm
by saika0321
Hello, I'm a game developer in Korea. I'm using a translator because I'm not good at English, so there may be some expressions that don't fit the grammar. I apologize for that in advance.

I added a Shake animation to the Dialogue Panel of the default built-in UI Prefab. I created an animation by repositioning the Subtitle Text on a frame-by-frame basis to give the Subtitle Text a shaking effect, and I also added a trigger to the animator.

And I made it possible to go to the Shake State if the 'Shake' trigger is executed in the Show State of the existing animator.

What I'm curious about is how to activate the Shake effect on certain lines. I thought it'd be better to use Sequence from Dialogue System, but I don't know how to change the animator's status to Shake.

To implement that function, if the method I thought was appropriate, I would appreciate it if you could tell me the exact usage method.
If the approach itself is wrong, please let me know another way.

Re: Questions about implementing the effects of shaking the Subtitle Text

Posted: Wed Feb 26, 2025 3:54 pm
by Tony Li
Hello,

A sequencer command is fine. You could use the AnimatorPlay() or AnimatorTrigger() sequencer command.

Alternatively, you can add a script with an OnConversationLine(Subtitle) method to the Dialogue Manager. In this method, check the dialogue text for a special tag of your choosing, such as "<shake>". Set the animator accordingly. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.formattedText.text.Contains("<shake>"))
    {
        subtitle.formattedText.text = subtitle.formattedText.text.Replace("<shake>", "");
        SetShake(true);
    }
    else
    {
        SetShake(false);
    }
}
void SetShake(bool value)
{
    var animator = DialogueManager.standardDialogueUI.conversationUIElements.mainPanel.GetComponent<Animator>();
    animator.SetBool("Shake", value);
}