• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

image_index goes to -1 after upgrade

beanflip

Member
After the upgrade to v2.3, when using the animation_end event I see some animations start with frame -1. It only happens if the current animation has fewer frames than the sprite_index you're transitioning to. Here are a couple of examples:

GML:
if sprite_index==mike_legs_turningR//8 frames
{
sprite_index=mike_legs_walking;//32 frames
image_index=20;
}
//The sprite_index changes to mike_legs_walking but the first frame is set to -1 instead of 20, followed by 21, 22, etc. If I change it from 20 to 7 or lower it works

else if sprite_index==mike_legs_landing//4 frames
{
sprite_index=mike_legs_standing;//8 frames
image_index=7;
}
//Same thing here. If I set it from 7 to 3 the image_index never goes to -1
It seems to know what image_index it's supposed to be on, it just replaces the first one with -1. I've been doing it this way since Game Maker 6.x. It doesn't seem like a change they would make on purpose.

Edit: Typo.
 
Last edited:

Roldy

Member
After the upgrade to v2.3, when using the animation_end event I see some animations start with frame -1. It only happens if the current animation has fewer frames than the image_index you're transitioning to. Here are a couple of examples:


GML:
if sprite_index==mike_legs_turningR//8 frames

{

sprite_index=mike_legs_walking;//32 frames

image_index=20;

}
//The sprite_index changes to mike_legs_walking but the first frame is set to -1 instead of 20, followed by 21, 22, etc. If I change it from 20 to 7 or lower it works

else if sprite_index==mike_legs_landing//4 frames
{
sprite_index=mike_legs_standing;//8 frames
image_index=7;
}
//Same thing here. If I set it from 7 to 3 the image_index never goes to -1
It seems to know what image_index it's supposed to be on, it just replaces the first one with -1. I've been doing it this way since Game Maker 6.x. It doesn't seem like a change they would make on purpose.

What does 'image_index' equal after you set it. e.g.
GML:
if sprite_index==mike_legs_turningR//8 frames
{
    sprite_index=mike_legs_walking;//32 frames
    image_index=20;
    show_debug_message(string(image_index)); // Does this print 20 or -1
                                         // If it prints 20 then when does it change
                                         // continue to monitor for the rest of the frame
                                         // to determine when/what changes it
                                        
                                         // If it prints -1 then that is a bug for sure.



}
 

beanflip

Member
Please file a bug report.
Thank you. I'll submit a nice file for you guys soon.

What does 'image_index' equal after you set it. e.g.
GML:
if sprite_index==mike_legs_turningR//8 frames
{
    sprite_index=mike_legs_walking;//32 frames
    image_index=20;
    show_debug_message(string(image_index)); // Does this print 20 or -1
                                         // If it prints 20 then when does it change
                                         // continue to monitor for the rest of the frame
                                         // to determine when/what changes it
                                       
                                         // If it prints -1 then that is a bug for sure.



}
draw_text kicks back -1 while show_debug_message kicks back 20. If I put another show_debug_message(string(image_index)); at the very bottom of my 1700 lines of code in animation_end it kicks back 20 again.
 

Yal

šŸ§ *penguin noises*
GMC Elder
My guess is that there's some failsafe code that auto-loops the image_index if it exceeds the max numbers of the current sprite, which is now triggered when you update image_index because the number it caps with isn't updated the moment you change sprites, resetting it to -1 (so that it'd reach 0 again next update step).

I've heard rumors that the sprites are now sequence objects under the hood, so this little intricacy might've gotten lost in the translation (i.e, the sequence doesn't run an update step until a later point in the next game step, so some variables still use stale values).
 

Roldy

Member
Thank you. I'll submit a nice file for you guys soon.



draw_text kicks back -1 while show_debug_message kicks back 20. If I put another show_debug_message(string(image_index)); at the very bottom of my 1700 lines of code in animation_end it kicks back 20 again.

Alright so it is changing between Animation End and the next Frames Draw Event, what about the next Begin Step what is the value of image_index? Alot of things will occur between Animation_End and the next frames Draw. You know it is changing between then and there. What is changing it?

Just keep going until you pin point where it changes. It is either going to be somewhere in an event you have control over (and you can potentially fix yourself) or somewhere between events, internal to GMS and you'll have to put in a bug report for a potential fix. The closer you pinpoint the moment (cause) of the value changing then the quicker you yourself or YoYo will be able to fix it.

In the past (2.2.5) image_index gets advanced and rolled over right before Animation_end. But with the 2.3 changes they may be adjusting it at another time.
 

Roldy

Member
So I ended up installing 2.3. Along side a 2.2.5 installation and did AB test.

The difference seems to be:

In 2.2.5 BEFORE animation end;
  1. image_index is advanced
  2. roll_over is detected
  3. roll_over is applied to image_index
  4. animation_end will get called

In 2.3 BEFORE Animation end
  1. image_index is advanced
  2. roll_over is detected
  3. animation_end will get called
In 2.3 AFTER Animation end
  • roll_over is applied to image_index


An immediate work around would be to not change sprite_index inside Animation End. Delay, and set a variable to know that it needs to change in the next Begin Step.

EDIT:Actually it seems that roll over is also applied anytime you set image_index or change the sprite index.
 
Last edited:

GapingPixel

Member
Yeah this is a thing. Had to manually set the image index after sprite switching. Lost some hours wondering why some of my player states tied to the animation end event were acting so weird.
 

Roldy

Member
Yeah this is a thing. Had to manually set the image index after sprite switching. Lost some hours wondering why some of my player states tied to the animation end event were acting so weird.
It is actually really messed up. Kind of hard to explain.

But there seems to be an internal image_index that isn't exposed that keeps track of where it thinks it should be. Here is an example of some weird stuff.

GML:
/// Animation End
/// the sprite is originally 2 frames spr_2frame

show_debug_message(string(image_index)); // This prints 1.98 it is about to roll over after Animation End

var _temp = image_index; // Save off image_index
show_debug_message(string(_temp));  // _temp now also equals 1.98

sprite_index = spr_1frame; // Change the sprite to a single frame sprite
show_debug_message(string(image_index)); // This prints '0'.  image_index was changed when changing sprites and 'rolled over' due to image_index > image_number

image_index = _temp; // Set our image_index back to where it was '1.98'

show_debug_message(string(image_index)); // This prints '0.98' not '1.98'
                                                                       // It seems to be storing an internal image_index that is accounted for when making changes to the exposed image_index

Here is another weird example:


GML:
/// Begin Step
/// the sprite is originally 2 frames spr_2frame

/// print what image_index is when we enter begin step
show_debug_message("Begin Step " + string(image_index));

sprite_index = sprite0;
show_debug_message("Change to 1 frame: " + string(image_index));

sprite_index = Sprite2;
show_debug_message("Change back to 2 frame: " + string(image_index));

The output will be: (sprite with 27 FPS at 60 FPS room speed advance 0.45 per frame)

Begin Step: 0
Change to 1 frame: 0
Change to 2 frame: 0
Begin Step: 0.45
Change to 1 frame: 0.45
Change to 2 frame: 0.45
Begin Step: 0.9
Change to 1 frame: 0.9
Change to 2 frame: 0.9
Begin Step: 1.35
Change to 1 frame: 0 // WTH? Roll over was triggered by setting sprite_index, but we just lost our roll_over. Instead of 0.35 it got set to a flat zero
Change to 2 frame: 0 // Now our two frame sprite will never trigger animation end.
 
Last edited:

beanflip

Member
Alright so it is changing between Animation End and the next Frames Draw Event, what about the next Begin Step what is the value of image_index? Alot of things will occur between Animation_End and the next frames Draw. You know it is changing between then and there. What is changing it?

Just keep going until you pin point where it changes. It is either going to be somewhere in an event you have control over (and you can potentially fix yourself) or somewhere between events, internal to GMS and you'll have to put in a bug report for a potential fix. The closer you pinpoint the moment (cause) of the value changing then the quicker you yourself or YoYo will be able to fix it.

In the past (2.2.5) image_index gets advanced and rolled over right before Animation_end. But with the 2.3 changes they may be adjusting it at another time.
I created a very simple project and sent it with the bug report. Trying out a show_debug_message in the begin step does return -1. If animation_end is the last event to test and begin_step is the first I think we've narrowed it down all we can. It's changing from the correct frame to -1 before it has a chance to draw it.

I hope I don't have to come up with a work around for this because right now my game is very broken :(

edit: I left this window open so long my post is a bit outdated. Thanks for looking into this guys. Now I wonder if Yoyo will change back it or leave it be.
 
Last edited:

offalynne

Member
Have you received any message back from support? Is there an open issue in Mantis? This is a massive change with significant consequences.

right now my game is very broken
Some clarification from YYG would be welcome here instead of the problem being secreted away to an individual bug report response. It's hard to believe something so potentially catastrophic was not caught in beta.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Some clarification from YYG would be welcome here instead of the problem being secreted away to an individual bug report response.
The bug has been filed and accepted and the issue will be resolved in a coming update.
 

beanflip

Member
Have you received any message back from support? Is there an open issue in Mantis? This is a massive change with significant consequences.



Some clarification from YYG would be welcome here instead of the problem being secreted away to an individual bug report response. It's hard to believe something so potentially catastrophic was not caught in beta.
I'm happy to confirm it's on their to-do list. The devs got back to me pretty quickly. Maybe I should have posted it here but I was going to wait until they actually fixed it.

I agree that's it's a very destructive bug. I make heavy use animation_end to blend my hundreds of animations together.
 
I've mentioned this before but didn't get much of a response. There is definitely a problem with image_index's. My text system uses 1 whole sprite for a font, and different index's for characters. Some characters are printing wrong. For instance, "2" and "3" both print as "2". "r" prints as "Q". They are somehow just a bit off. This just started happening with 2.3. I haven't looked into fixing it because I have bigger things to work on, so I don't know exactly what's going on, but it seems like you guys figured it out.
 
Top