About the sprite2D error

I understand that the error indicates a frame number larger than the total number of frames in the sprite sheet has been specified. However, I’m confused because only 3 animation frames are defined, yet I’m being told there are more than 5 frames.

Since the game is running without issues, could there be some cached data causing this?

E 0:00:07:356 Sprite2D::set_frame: Index p_frame = 5 is out of bounds (vframes * hframes = 5).
<C++ Source> scene\2d\sprite_2d.cpp:256 @ Sprite2D::set_frame()

I believe I see the issue. In your animation the frame track is above the animation track. Tracks are applied top to bottom, so the frame value gets set first while the previous animation is still active. If that previous animation has fewer frames than the frame being set, you get the out of bounds error for a brief moment before the animation track switches over. That’s why the game still plays fine, the error only lasts one frame.

The fix is to reorder the tracks so the animation track is above the frame track. You can drag the track name to move it. That way the correct animation (and its frame count) is set before the frame index is applied.

One thing I noticed, the error mentions Sprite2D but your setup uses AnimatedSprite2D. If the error still appears after reordering, it might be coming from a different object, so check if any other animations have the same track ordering.

1 Like

Thank you for your response.

I swapped the track order and placed the animation track above the frame track, but the error persisted.

I also tried it on a test map with only the player, but the same error occurred.

Ok darn. Can you send the project files to us at pgmmv-support@gotchagotcha.jp so maybe we can look and see why it’s happening?

1 Like

Thank you. Please confirm.

Hello, I had some time to download the file you linked on here, but it is of the exported game. I would need the raw project files in a zip to the pgmmv-support@gotchagotcha.jp to further investigate what is happening internally. If you could send a new link with the project files we would gladly check it out for you!

1 Like

Thank you. I have sent the URL for the zipped project file via email.

Thank you for sending the project files, I found the cause!

The error is not coming from the player’s 07_walljump animation at all. It comes from the wall jump effect object, e_008_walljump_01.tscn. Its effect node is a plain Sprite2D, which matches the error text exactly. The player uses AnimatedSprite2D, so the player was never the source.

Here is what’s happening. The effect’s texture Eyebeam_002.png is 120x46 with hframes = 5, so the valid frame values are 0 to 4. But the animation walljump_01 in E_008_walljump_01.tres has a frame track with six keys, 0 through 5. When the final key sets frame 5, Godot prints the out of bounds error. The game still looks fine because that same animation fades the alpha to 0 at the exact moment the bad key fires, so the invalid frame is never visible. It’s only a one frame error each time you wall jump, nothing more.

I believe the animation was originally made for a 6 frame sheet. The dash effect e_008_dash_01.tscn uses Eyebeam_001.png with hframes = 6 and the same 0 to 5 keys with no problem. It looks like the 5 frame texture was swapped in for the wall jump version without adjusting the last key.

The fix:
Open the wall jump effect’s walljump_01 animation and change the last key on the effect:frame track from 5 to 4, or simply delete that key. There will be zero visual change since the sprite is fully transparent at that moment anyway. I also checked the other animations that key frames 0 to 5 and they target AnimatedSprite2D, so they can’t cause this error.

1 Like

Thank you. It has been successfully resolved.