character animation problem

Hello, i’m using ex2d for a 2d game in Unity; i have a character that moves left - right,
jumps with the specific animations: walk, jump, attack, crouch, idle. Everything is good
only there is one problem:
for example i press ‘‘d’’ he goes to right with the walk animation (that’s good), while doing that if i press the jump button (plays the jump animation) and release it doesn’t go
back to walk animation even if the ‘‘d’’ key is still pressed (he still moves to the right,
but with the idle animation).

Here is my ‘‘animations’’ script:

function Update (){

spAnim = GetComponent(‘exSpriteAnimation’);

if(Input.GetKeyDown(‘a’))

spAnim.Play('ca_walk');	

if(Input.GetKeyUp(‘a’))

spAnim.Play('ca_idle');	

if(Input.GetKeyDown(‘d’))

spAnim.Play('ca_walk');	

if(Input.GetKeyUp(‘d’))

spAnim.Play('ca_idle');

if(Input.GetKeyDown(‘s’))

spAnim.Play('ca_crouch');	

if(Input.GetKeyUp(‘s’))

spAnim.Play('ca_idle');	

if(Input.GetKeyDown(‘j’))

spAnim.Play('ca_attack');

if(Input.GetKeyUp(‘j’))

spAnim.Play('ca_idle');	

if(Input.GetKeyDown(‘k’))

spAnim.Play('ca_jump');	

if(Input.GetKeyUp(‘k’))

spAnim.Play('ca_idle');	 

}

The problem goes for any key combination(press one button - plays specific animation, press one more button - plays its animation but after that second button is released it wont go back to the first animation even if that button is still pressed)
It has to recognize that the first button is still pressed after another one’s action or something like that;
Thank you in advance,

I think what’s happening is as soon as you let the second button go the idle animation is always played and you only want it to play if there is no input…
Maybe try this instead:

function Update (){

spAnim = GetComponent(‘exSpriteAnimation’);

if(Input.GetKeyDown(‘a’))
{
spAnim.Play(‘ca_walk’);
}

if(Input.GetKeyDown(‘d’))
{
spAnim.Play(‘ca_walk’);
}

if(Input.GetKeyDown(‘s’))
{
spAnim.Play(‘ca_crouch’);
}

if(Input.GetKeyDown(‘j’))
{
spAnim.Play(‘ca_attack’);
}

if(Input.GetKeyDown(‘k’))
{
spAnim.Play(‘ca_jump’);
}

if(!Input.GetKeyDown(‘a’) && !Input.GetKeyDown(‘d’) && !Input.GetKeyDown(‘s’) && !Input.GetKeyDown(‘j’) && !Input.GetKeyDown(‘k’))
{
spAnim.Play(‘ca_idle’);
}

}

Try something like this:

function Update (){

	spAnim = GetComponent('exSpriteAnimation');
	
	if(Input.GetKeyUp('a') || Input.GetKeyUp('d') || Input.GetKeyUp('s')) {
		spAnim.Play('ca_idle'); 
	}
	
	if(Input.GetKey('a') || Input.GetKey('d')) {

		spAnim.Play('ca_walk');
	} 

	if(Input.GetKeyDown('s')) {

		spAnim.Play('ca_crouch');   

	}	

	if(Input.GetKeyDown('j')) {

		spAnim.Play('ca_attack');

	}

	if(Input.GetKeyDown('k')) {

		spAnim.Play('ca_jump');
	
	} 

}