I am developing some text events in my game right now that will update automatically and animate in/out while the player moves (for tutorials and narration purposes). I noticed whenever the AnimationPlayer runs, my input gets paused. Very strange, as it's not linked to the player at all. What noob thing am I missing? I am not using yields.
Here is my AutoTextEvent class which will have another class as child (TextBox):
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 here is the textbox object, pretty basic.
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")
# yield(self,"animation_finished")
_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