0 votes

I have this automated text event I am using to display narration/tutorials/blah-blah-blah and for some reason, whenever the text updates/animates, my player input decides to lock up until the animation is done. I am not using yields or anything so I am a bit curious as to how this is happening. Help appreciated. (Note: my input is only four buttons. Left, right, space and shift).

Here is my event:

    extends Node2D


var _isFaded = false
var _textQueue = 1
export var _BF = 3
export var _textLine1 : String
export var _textLine2 : String
export var _textLine3 : String
export var _textLine4 : String
export var _autorun : bool
const _empty = ""

onready var _fade = $TextBox
onready var _text = $TextBox/TextLabel
onready var _timer = $Timer


func _ready():
    if _autorun == true:
        _textUpdate()


func _textUpdate():
    match _textQueue:
        1:
            _fade._update_(str(_textLine1))
            _fade._show_()
            _timer.start(_BF)
            _textQueue = _textQueue + 1
        2:
            if _textLine2 == _empty:
                _end_text()
            else:
                _textQueue = _textQueue + 1
                _fade._update_(str(_textLine2))
                _fade._show_()
                _timer.start(_BF)
        3:
            if _textLine3 == _empty:
                _end_text()
            else:
                _textQueue = _textQueue + 1
                _fade._update_(str(_textLine3))
                _fade._show_()
                _timer.start(_BF)
        4:
            if _textLine4 == _empty:
                _end_text()
            else:
                _textQueue = _textQueue + 1
                _fade._update_(str(_textLine4))
                _fade._show_()
                _timer.start(_BF)
        5:
            _end_text()


func _end_text():
    _fade._vanish_()
    self.queue_free()

func _on_Timer_timeout():
    _fade._vanish_()

func _on_TextBox_animation_finished(_anim_name):
    if _text.modulate.a == 1:
        _fade.stop()
    else:
        _textUpdate()

And this here is my TextBox object that the above class is referencing.

extends AnimationPlayer

class_name DialogueBox

## local variable showing text is 100%/idle
var _text_display = false
onready var _words = $TextLabel


## func to update text
func _update_(_string):
    _words.set_text(_string)


## func to show, with flag to stop player movement
func _show_():
    Director._eventFlag = true
    self.play("showText")
    _text_display = true


## func to vanish and prevent double trigger, player movement unlocked
func _vanish_():
    if _text_display == true:
        self.play_backwards("showText")
        _text_display = false
        Director._eventFlag = false
Godot version v3.4.3.stable.official [242c05d12]
in Engine by (548 points)

What does the code Director._eventFlag = true do exactly? How does it affect the player?

Oh. My. God.
I just saw that. It’s exactly as I coded it.
Wowwwwwwwww.

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.