C#: How do I change Sprite2D frame through parent node's script?

Godot Version

Godot_v4.2.1-stable_mono_win64

Question

Hi, I want to change my Sprite2D’s current frame using my player script. I tried this, but it didn’t work:

GetNode(“Sprite2D”).frame = 1;

I get the error that ‘Sprite2D’ contains no definition for ‘frame’.
Frame is under the ‘Animation’ property of the Sprite2D, and I have my sprite sheet divided into 8 columns.
For now, all I want to do is set it to one of those 8.
I also tried capitalizing frame, putting animation before frame (capital and lowercase), nothing has worked.
I couldn’t find any documentation on this, so I would really appreciate some help!

For some reason, the part with the less than and greater than symbols with 'Sprite2D in the middle doesn’t show, but it is there.

Hello, try this.
GetNode("Sprite2D").Frame = 1;
Frame with a capital letter.
In C# almost all properties, functions, etc. starts with capital letter.

I thought I’d already tried that, haha. I probably didn’t save the script…
Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.