fix: Safety guard for characters without speaking animations (#457)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-22 15:09:37 +01:00
committed by GitHub
parent 879022217c
commit f4c5803646
2 changed files with 7 additions and 3 deletions

View File

@@ -442,7 +442,9 @@ func turn_to(object: Node, wait: float = 0.0):
# Play the talking animation
func start_talking():
if get_animation_player():
if get_animation_player() and \
_movable.last_dir >= 0 and \
_movable.last_dir <= animations.speaks.size():
if get_animation_player().is_playing():
get_animation_player().stop()
get_animation_player().play(
@@ -452,7 +454,9 @@ func start_talking():
# Stop playing the talking animation
func stop_talking():
if get_animation_player():
if get_animation_player() and \
_movable.last_dir >= 0 and \
_movable.last_dir <= animations.idles.size():
if get_animation_player().is_playing():
get_animation_player().stop()
get_animation_player().play(