For doors that go between scenes in no signal, I've had this pattern of creating an extra pair of animations to easily switch to the open or closed state of a door, for a total of four animations:
open- The open animationclose- The close animationopened- A single frame which sets the door to the opened stateclosed- A single frame which sets the door to the closed state
Setting up this extra animation is tedious, but
it was something I did because I wasn't sure how to
play the last frame of an animation. However, when I
was implementing the ability to save and load the
state of other doors in the game, I found out that
many of them don't have an opened and
closed animation and I was reluctant to
make them, so I explored how to do it again.
As expected, the paths that I probably tried before didn't seem to work in Godot 4.3.stable.
The following attempt fails, because it still
plays the opening sound despite the fact that
update_only is true. I suspect this is
because the sound is played on the very first
frame.
play("open")
seek(get_animation("open").length, false, true)The following also fails, as the door fails to open at all:
play_backwards("open")
stop()I thought this was because the
play_backwards function didn't actually
do anything until the next process, but manually
requesting and update didn't work either:
play_backwards("open")
advance(0)
stop()However, I noticed that the documentation for
play_backwards mentioned that it was
the same as play, but with
custom_speed = -1.0 and
from_end = true. This is very similar
to what I want, except with a
custom_speed of 0 since I
don't want the animation to play. Calling the
play function myself appears to
work:
play("open", -1, 0, true)