• 2D
  • Changing frame of a sprite using a script?

I don't want the object to be animated, but I want to be able to change the sprite based on criteria in the script. I have a sprite with a sprite sheet as its texture and I have the frames set up correctly, I just don't know how to change the frame

If you take a look at the inspector while the sprite node is selected, you'll see a section called "Animation" and there, you can see there's an entry for "frame".

All of these variables can be accessed through script, and have virtually the same names (maybe with some underscores added.) Just set your sprite's frame variable to another number and the frame will change.

Intellisense will usually show you the proper variable, but if all else fails, remember that the docs have all the info you need about every node:

https://godot.readthedocs.io/en/latest/classes/class_sprite.html

int frame - Current frame to display from sprite sheet. vframes or hframes must be greater than 1.