Reputation: 433
I'm using Godot 4 beta. I want to skip to a specific frame in an AnimationPlayer
, but I'm getting:
Invalid set index 'current_animation_position' (on base: 'AnimationPlayer') with value of type 'float'.
Here's the related documentation: https://docs.godotengine.org/en/latest/classes/class_animationplayer.html#class-animationplayer-property-current-animation-position
I currently have one AnimationPlayer
in my scene, named 'animation'
, with an animation named 'Animation'
with "Autoplay on Load". The animation 'Animation'
has a length of 4.x seconds.
Here's my code attached to the scene:
func _process(_delta):
if Input.is_action_just_released("skip_intro"):
if animation_player.current_animation_position < 1.3:
animation_player.current_animation_position = 1.3
else:
skip_intro()
I know I can use animation_player.advance()
, but it adds to the relative time. I'm looking for a way to go to a fixed frame, not a relative frame.
Upvotes: 1
Views: 3364
Reputation: 40170
As you can read in the documentation you linked current_animation_position
only has a getter. It is a read-only property.
If you want to go to an specific time you can use the seek
method.
Upvotes: 1
Reputation: 433
I found that I can use play()
before advance()
to go to an absolute frame. But I'd appreciate any other way to do it inliner.
animation_player.play("Animation")
animation_player.advance(1.3)
IMO it should be allowed to rewrite the current_animation_position
property.
Upvotes: 0