+3 votes

My goal is to create a cutscene where the first scene is a page that has a traditional animation on it, and the following scene has "typwriter" text that executes via the following script:

extends RichTextLabel

var lapsed = 0
var charNum = 0

func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    lapsed = lapsed + delta

    get_visible_characters()

    charNum = set_visible_characters(lapsed / .03)

My problem is the "typewriter" text finishes typing while the first scene is animating. When I play the second scene by itself the "typewriter" text works.

I think I need a way to freeze the 2nd animation until the first animation is done. How would I go about doing this?

By the way, I started down t his path because I noticed using AnimationPlayer to animate text visibility in a RichTextLabel, just doesn't work.

Thanks in advance for any help!

in Engine by (88 points)
retagged by

UPDATE 1:
I fixed my own issue by just initializing "lapsed" in _ready() to "0". I now understand a bit more about how to use _ready().

extends RichTextLabel

var lapsed = 0
var charNum = 0

func _ready():
    set_fixed_process(true)
    lapsed = 0 # <<<< Added this

func _fixed_process(delta):
    lapsed = lapsed + delta

    get_visible_characters()

    charNum = set_visible_characters(lapsed / .03)

UPDATE 2:
Ah, I just noticed that I did need to kick off _ready() with a signal. In my case I kicked off the _ready() of the node I wanted to work with using a signal. The following code snippet is what I did to make this work, combined with UPDATE 1:

trigger_node.connect("visibility_changed", observer_node, "_ready")

UPDATE 3:
I noticed there was a visible flicker when the typewriter text initially appeared so I tweaked the code to setvisiblecharacters() to 0 like so:

extends RichTextLabel

var lapsed = 0
var charNum = 0

func _ready():
    set_fixed_process(true)
    lapsed = 0
    set_visible_characters(0) # <<<< Added this

func _fixed_process(delta):
    lapsed = lapsed + delta

    get_visible_characters()

    charNum = set_visible_characters(lapsed / .03)

Thank you for creating this, it's awesome!!

Thank you for the appreciation! :)

1 Answer

+1 vote

It didn't work for me in 2020 but if anyone wants to do something similar this works

var lapsed = 0


func _ready():
    lapsed = 0

func _physics_process(delta):
    lapsed += delta
    visible_characters = lapsed/0.1
by (20 points)

This works great, thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.