I have a character who has two states: run and idle. I also have 2 sprite Sheets, where one has sprites for run animation (consists of 12 sprites), and the other for idle animation (consists of 5 sprites). To switch between these animations, I change the texture in Sprite2D of the character from one to another and change the value of h_frame from 5 to 12 and vice versa. Then an animation is launched on Animation Player, which changes frame_coords.x so that the animation works.
When the game starts, the idle animation works correctly, however, when I switch to the run state, the animation breaks and an error appears in the console
set_frame_coords: Index p_coord.y = 6 is out of bounds (vframes = 5)
I suspect this is because the idle sprite sheet has fewer frames than the run. I have already checked this, if I do not change the value of h_frame, then the animations are played and the error does not appear, however, in this case the animation does not look as intended.
Any solutions?