Manually Switch to different frames of an animated 3D sprite

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By YuleCrow

I was wondering what code I would use to manually switch to a different frame in an animated 3D sprite’s animation when certain conditions are met.

e.g. the ‘animation’ is simply two textures to show a permanent change in the sprite but this only happens after an if statement’s conditions are met.

:bust_in_silhouette: Reply From: jgodfrey

I think you’re looking for the frame property of an AnimatedSprite3D object. Docs here:

I’m sorry but I don’t really understand their docs and was more looking for a code to write into the script if that’s okay

YuleCrow | 2023-03-21 11:51

You can just assign a specific frame number to the frame property to change to a given frame. So, for example, to change to frame #2, this:

$AnimatedSprite3D.frame = 2

jgodfrey | 2023-03-21 18:35

Worked, thank you! (sorry for the late reply)

YuleCrow | 2023-03-22 15:18

Thank you for solving the problem. I was struggling around and look I found your answer,

hasnatkhan420 | 2023-03-23 13:07