0 votes

Thanks in advance

Godot version 3.3.2
in Engine by (25 points)

1 Answer

0 votes

$Animationplayer.play('animation_name')

by (655 points)

Sorry if I was not clear. My question was meant to understand how can I get the sprite currently playing in the animation player.

If the animation "running" has 5 frames, and it is right now on the third frame, how can I get the third frame in the form of a Sprite object?

I was looking for something like:

$AnimationPlayer.getcurrentframe_sprite()

Okay I see. If you are using a spritesheet then this is not possible as far as I know. The animationplayer is just animating the texture, Its not turning it into a sprite node. Though if you use an animated sprite there is a get_frame( ) function for that node.

But if your are trying to get a certain frame to make something happen, then the animation player can call functions on a specfic frame. Its a very powerful node in that aspect. Not sure if that clears things up

Yes it is possible, found it on this video: https://www.youtube.com/watch?v=SnvdvnJUYxE

Basically you do pass to a sprite object the hframe vframe frame and texture:

otherSprite.texture = $Sprite.texture
otherSprite.vframes = $Sprite.vframes
otherSprite.hframes = $Sprite.hframes
otherSprite.frame = $Sprite.frame
otherSprite.scale = self.scale

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.