Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Set animation position

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Editor (1)

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()

Update (2)

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.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading