Checking if the player is moving.

I’m having an issue if i press both the up and down keys at the same time, because if i do my vertical input equals 0 and this will fail.

function IsMoving ()  : boolean
{
	return Mathf.Abs(Input.GetAxisRaw("Vertical")) + Mathf.Abs(Input.GetAxisRaw("Horizontal")) > 0.5;
}

How do you get around this? Thanks!

Your going about this the wrong way.

if(Input.GetButtonDown("w")){
//the character is moving
abc();
}
if(Input.GetButtonDown("a")){
//the character is moving
abc();
}
if(Input.GetButtonDown("s")){
//the character is moving
abc();
}
if(Input.GetButtonDown("d")){
//the character is moving
abc();
}

//There's probably an easier way then doing five if's....

function abc(){
//Action you want if character is moving
}

how about

if (!Input.GetButtonDown("w") || !Input.GetButtonDown("a") || (Etc...))
playerIsMoving = false;
else
playerIsMoving = true;

Pseudocode, of course. There’s PROBABLY a hash… bit… thingy somewhere (maybe something along the lines of Input.GetButtonDown(any) but I’m not sure) that just checks to see if buttons are being pressed.