Help Animating a Texture

Im using a script off of the wiki to animate my texture:

This basically is what turns a 2D SpriteSheet into an animated character.

Here’s the code I’m using to assign keys to each row of the SprieSheet:

I have a 4x4 Sprite Sheet, the rows start at 0 instead of 1. (row = 0 would be the first row)

Anyway, As you can see I assigned multiple keys to two specific rows, you can read the comments in the code for more detail. But for some reason its only showing row 0 and row 1
And the Unity console isnt even giving me errors.

Sprite Sheet:

Row 0 is my character just stationary

Row 1 is of my character running

Row 2 is of my Character shooting, while stationary

Row 3 is of my character Shooting, while running

The game plays as if Rows 2 and 3 just dont exist, nor do the lines in the code.

Sorry if I dont explain very well, Im very, very new to Java and Unity.

Anyone have an idea whats going wrong?

Your if statement in you second image won’t ever set the state to 2 or 3 because as soon as you do you change it to 0 or 1.

You need to change your code to be logically like the following. ( this is not functional code but should help you restructure your code)

If( keydown(w) && keydown(a) )
    ShowFrame = 2
else if ( keydown(w) && keydown(d) )
    ShowFrame = 3
else if ( keydown(w) )
     ShowFrame = 3
else if ( keydown(a) || keydown(d) )
    ShowFrame =  1
     ShowFrame = 0