![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | arknvi909 |
Hello. Attempting to make a simple first game and I’m working on a scene that picks out random animations and then plays them with dialog (using dialogic) between each animation. However, it seems like the first animations/dialog is being skipped and only the first one is being played. Here is a simple example of the my code. I have taken it out of a for loop.
extends Node2D
onready var animation = $walk_choices/AnimationPlayer
var choices = ["walk1", "walk2"]
func _ready():
randomize()
var random = RandomNumberGenerator.new()
random.randomize()
var dialog_1 = Dialogic.start("/normal_encounter")
var dialog_2 = Dialogic.start("/normal_encounter")
var animation_choice_1 = get_random_animations()
var animation_choice_2 = get_random_animations()
animation.play(animation_choice_1)
add_child(dialog_1)
dialog_1.connect("timeline_end", self, 'after_dialog')
#Add something here to wait until first dialog is finished?
animation.play(animation_choice_2)
add_child(dialog_2)
dialog_2.connect("timeline_end", self, 'after_dialog')
func get_random_animations():
var choice_int = randi()%2+0
var random_selection = choices[choice_int]
return random_selection