Animations not working

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(NetworkView))]
public class WalkPath : MonoBehaviour {
	public GameObject[] points;
	public int onRouteTo;
	public string idleAnim = "idle1";
	public string walkAnim = "walk";
	private GameObject me;
	public Transform target;
	public int moveSpeed = 2;
	public int rotationSpeed = 3;
	private Transform myTransform; 
	public int maxDistance;
	private float footTimer = 0;
	private CharacterController _cc;
	private bool halted = false;
	private float haltTime;
	private string currentAnim = "walk";
	public string tag;
	private string lastAnim;

	// Use this for initialization
	void Start () {
		me = this.gameObject;

		if(Network.peerType == NetworkPeerType.Server){
			onRouteTo = 0;
			points = GameObject.FindGameObjectsWithTag(tag);

			target = points[onRouteTo].transform;
			_cc = GetComponent<CharacterController>();
			
			maxDistance = 1;
			myTransform = transform;
		}
	}

	void OnEnable(){
		Messenger.AddListener ("Halt", Halt);
	}

	void OnDisable(){
		Messenger.RemoveListener ("Halt", Halt);
	}

	private void Halt(){
		if(Network.peerType == NetworkPeerType.Server){
			halted = true;
			haltTime = 2;
		}
	}

	// Update is called once per frame
	void Update () {
		PlayAnim ();

		if(Network.peerType == NetworkPeerType.Server){
			//look at target
			myTransform.rotation= Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);	
		
			if(Vector3.Distance(target.position, myTransform.position) > maxDistance){		
				if(!halted){
					_cc.SimpleMove(myTransform.TransformDirection(Vector3.forward) * 2);
					WalkAnim();
				}
			}
			
			if(Vector3.Distance(target.position, myTransform.position) <= maxDistance){		
				//Move towards Target(Player)
				onRouteTo++;
				
				if(onRouteTo > points.Length)
					onRouteTo = 0;
					
				target = points[onRouteTo].transform;
			}
			
			if(_cc.isGrounded == false){
				_cc.SimpleMove(myTransform.TransformDirection(Vector3.down) * 1);
			}

			if(haltTime > 0){
				haltTime -= Time.deltaTime;
				IdleAnim();

				if(haltTime <= 0){
					halted = false;
					haltTime = 0;
				}
			}
		}

	}

	void PlayAnim(){
		me.animation.CrossFade(currentAnim);
		//if(lastAnim != currentAnim){
		//	Messenger<string>.Broadcast("PlayAnim", currentAnim);
		//	lastAnim = currentAnim;
		//}
	}

	void IdleAnim(){
		networkView.RPC("SyncAnim", RPCMode.All, idleAnim);
	}
	
	void WalkAnim(){
		networkView.RPC("SyncAnim", RPCMode.All, walkAnim);
	}

	[RPC]
	void SyncAnim(string theAnim){
		currentAnim = theAnim;
	}
}

I have a script set up so a NPC (That is spawned in with another script when the game is a server) walks on a set path around a town. However Animation.crossfade doesn’t work, and niether does animation.Play.

I debugged it a bit and I know the PlayAnim is being played I’ve moved where its being called a bit and it doesn’t work, and I know that the script is trying to run the correct anim so I’m not sure what to do.

Thanks in advance for help.

Does your NPC have an animation component?

I think it needs one if you’re using animation.play or .crossfade.

It must have those animations attached to it.