GML Image_Index not being evaluated as expected

S

Snayff

Guest
Evening all,

I am looking to shift states when an animation has hit a certain frame (the cast frame), in this case represented as stateVar[0] and it is equal to 4. However, the formula evaluates false under the below circumstances, which doesnt seem right to me! It actually seems to resolve as true after a few loops.


Code:
if image_index >= stateVar[0] {
    scStateChkSwAirborne();
   [...]
}

Code:
draw_text(x ,y + 6, 
   + "\n IMG_index: " + string(image_index)
 );



Shots from the same paused frame:
upload_2017-11-4_21-57-23.png
upload_2017-11-4_21-58-39.png



So, firstly I am unsure why the image index shows differently in the game, when shown as a string, to in the debugger. Does the string conversion cause an issue? And secondly, the in game debug string seems accurate for my other calculations, so I am not sure what I am missing here!

Any help would be appreciated.

Snayff
 
P

Pixels_Everywhere

Guest
I have this problem too. My fix is to do something a little messier, but it seems to work consistently.
if ((image_index >= 2) && (image_index <= 2.1)) { YOUR CODE HERE }
 
S

Snayff

Guest
Thanks for the reply mate. What is your image_speed and do you need to take it in to account for the upper boundary? My speed changes so it is a bit more difficult to predict where it will be.
 
Top