SOLVED Entering If Statement even when the If criteria is false

SophosMoros

Member
I cannot for the life of me figure out why this if statement continues to execute even when it's false. I'm trying to reset a sprite animation when you first switch to it and for some reason it keeps entering the first if and holding the image index at 0 instead of it running one time when you switch to the new sprite and then running the sprite index as normal. I've tried writing this in more ways than i can count and for some reason it always wants to enter that if statement that resets the image_index to 0.


GML:
        if(slide == true)
        {
       
            if (move == 1)
            {
                if(sprite_index != spr_hero_slide_right)
                {
                    sprite_index = spr_hero_slide_right
                    image_index = 0;  
                }              
                   
                else sprite_index = spr_hero_slide_right
               

            }
 
Last edited:

SophosMoros

Member
It returns 1 which is what I expected. The odd part is that I did the same for sprite_index and it is not giving me the correct sprite index. Its giving me the id for the sprint sprite and not the slide, even though in the game it's performing the first sub image of the slide animation. Now I'm even more confused. I had some debug text in a draw gui event
GML:
draw_text_transformed(400, 160, "sprite index " + string(obj_player.sprite_index), 2, 2, 0);
And in that it's giving me the ID for the slide animation when I'm sliding but the show_debug_message() function is not... wtf
 

SophosMoros

Member
I figured it out, higher up in that function was a condition that was getting set that was changing the sprite every step before it got to the slide portion. I moved it up so it was evaluated first and it fixed it. Stupid Stupid Stupid me. Thanks for your help.
 
Top