+1 vote

I have created a scene for a door, which has a hook for a signal when a user is trying to open the door. When this is called, it checks to see if the door the player is trying to open is the current one, and if so, it calls $AnimationPlayer.play("Open").

Several print_debug calls confirm it is making the call to play on the correct instance, but the animation actually occurs on the other instance.

The code that handles the entering_door signal can be found below:

func _on_Player_entering_door(door):
    print_debug("player entering door " + door.name)
    if self.name.nocasecmp_to(door.name) == 0:
        print_debug("starting animation for " + self.name)

Is this normal behaviour? If so, how would one approach having an instanced scene that contains animations?

My idea behind this was to create a scene which will let me hook up a few signals and then have multiple doors in the parent scene that are all consistent and can be managed with one set of code etc.

in Engine by (24 points)

Is it always the same door that opens no matter which door you are actually interacting with? Or is it always just the other door?

Yes - the print_debug call will always say it is starting the animation for the correct instance, but it's always the other sprite that actually animates

What does your scene tree look like?

Would you be able to share the project?

I have uploaded a copy here with the art work replaced with arbitrary shapes: https://drive.google.com/open?id=1Q9Gsr6hj8STzqBMjm9eRdsrSRUZhBnTT

You can move the blue square (Player) with the A and D keys, and then when in front of a door (the red blocks), if you hit the W key, it will begin the animation process after ~1 second and you'll find the only one that animates is the one on the far right.

@Eric Ellingson, I managed to find the cause of the bug. I have just posted an answer for it in case you're interested in seeing the details (TLDR: the path to the sprite in the animation player was absolute instead of relative)

2 Answers

+1 vote
Best answer

I managed to find the issue - it was the reference to the target sprite in the AnimationPlayer. Some how, it had an absolute path, rather than a relative one. After changing this to a relative path to the sprite that was being animated, it works now

by (24 points)

Ok, but how did you do that ?

By double clicking the track name in the animation player and changing the path

0 votes

I have came into similar problems. And my solution is make specific "Animation" in the "AnimationPlayer" local to scene.

In detail, click "Animation" button in the "AnimationPlayer editor", and choose "Open in the Inspector", then on the inspector panel, find "Resource"->"Local to Scene" and tick it.

by (14 points)
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 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 webmaster@godotengine.org with your username.