using UnityEngine; using System.Collections;
public class ClickToMoveScript : MonoBehaviour
{
public string Chopping = "Chopping";
public void PlayWoodCuttingAnim()
{
//Play Woodcutting Animation
gameObject.GetComponent<Animation>().CrossFade (Chopping);
}
}
Heres my other Script
using UnityEngine;
using System.Collections;
public class WoodCuttingScript: MonoBehaviour
{
ClickToMoveScript ClickToMove;
void Start()
{
ClickToMove.PlayWoodCuttingAnim();
}
}

I have already added the animation inside the animation component.
The other thing i found out is that if i call the PlayWoodCuttingAnim() function inside ClickToMove script it works fine but in the other script it dosent work.
The error console > NullReferenceException: Object reference not set to an instance of an object.
Any help would be greatly appreciated
ClickToMoveScriptattached to another gameObject?ClickToMove = new ClickToMoveScript();beforeClickToMove.PlayWoodCuttingAnim();or attach ClickToMoveScript to the gameObject and dogameObject.GetComponent<ClickToMoveScript>().PlayWoodCuttingAnim();insteadClickToMove.PlayWoodCuttingAnim();