I have an animation player that plays animations according to a custom clock I set up, when one animation ends in one scene it starts the next in another, this works perfectly. Everything is working fine in my code except if I were to click a button and enter the next scene before the current animation can finish ( I enter the next scene too early), it keeps playing the same animation , but now in the wrong scene. I understand if this sounds confusing.
below is my code:
func _ready():
if SceneChange.Current_Scene == "Main Street":
if WorldClock.ExactWorldClockTime <= 4.0:
$DiderAnimationPlayer.play("Dider_10_AM")
st = WorldClock.ExactWorldClockTime - 4.0
$DiderAnimationPlayer.seek(st)
if SceneChange.Current_Scene == "Diders Room":
if WorldClock.ExactWorldClockTime >= 4.0 and WorldClock.ExactWorldClockTime <= 20.0:
$DiderAnimationPlayer.play("Dider_10_15_AM")
st = WorldClock.ExactWorldClockTime - 4.0
$DiderAnimationPlayer.seek(st)
and
Below is a snippet from my autoload related to my problem:
#Signifies current scene
onready var Current_Scene
#Main Street add & remove
func enter_main_street():
add_child(Main_Street)
Current_Scene = "Main Street"
#Diders Room add & remove
func enter_diders_room():
add_child(Diders_Room)
Current_Scene = "Dider Room"
The "if" statement I added to remedy my problem was the line saying "if SceneChange.Current_Scene == "Main Street": " and
if " SceneChange.Current_Scene == "Diders Room": ". SceneChange is an autoload and I'm checking if the Current_Scene string value is "Main Street" or "Diders Room" .
What my plan was with my "if" statement:
When a player clicks a button to enter a new scene, the "current_scene"s value is changed to "Main Street" or "Diders Room", then in my "if" statement I check to see if the value is what it is . . . that was my idea.
What it currently does:
When I start the game, No animations play at all.
If any of you can come up with a better way to make my animation player respond to my "if" statement I am all ears! Thank you!
P.S. without the SceneChange.Current_Scene . . . . . "if" statement, my animation plays fine but has the issues I I mentioned at the very top of the post. Also sorry if my code looks weird, I struggled to figure out how to post the code correctly on here.