Enemy Animations Not Transitioning

I currently have an Enemy character targeting my player, and playing a walk animation while moving, but when it stops, it does not transition to the idle, but continues to play the walk. Here is the code, any suggestions as to what I can be doing differently?
Thanks!

using UnityEngine;
using System.Collections;

public class EnemyAISphere : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed;
	//max distance from target before attack
	public int maxDistance;
	
	private Transform myTransform;
	
	void Awake() {
		myTransform = transform;
	}

	// Use this for initialization
	void Start () {
		GameObject go = GameObject.FindGameObjectWithTag("Player");
		
		target = go.transform;
		
		maxDistance = 2;
	
	}
	
	// Update is called once per frame
	void Update () {
		//Draws Targeting Line for Debugging
		Debug.DrawLine(target.position, myTransform.position, Color.green);
		
		if(moveSpeed > 0)
			animation.CrossFade("walk");
		else
			animation.CrossFade("idle");
		
		//NPC Look atTarget
		myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
		//NPC will move is its distance from target is greater then the max distance. Sets NPC range
		if(Vector3.Distance(target.position, myTransform.position) > maxDistance){
			//NPC Move Towards Targeting
			myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
		}
	}
	
}

Also, I’ve tried changing int moveSpeed to a float and get the results that i’m looking for in the Inspector when I change the values.

Let me gues:

MoveSpeed is a variable you set in the inspector, but is never decreased.
That would explain why idle is never called =)

If not, than please post the relevant lines of code where you are modifying moveSpeed.

	public int moveSpeed;

		if(moveSpeed > 0)
			animation.CrossFade("walk");
		else
			animation.CrossFade("idle");

Thats exactly it. I still relatively a noob, not that familiar with scripting in this context. What is the best way to set a value for move speed in code?

Ok, so i tried adding public int moveSpeed = 2 and it gives me walking while, but not Idle when it stops. I’ll keep tinkering.

Above is the only code that I’m using for NPC/Enemy movement.

thanks for pointing me in the right direction! Got it working!