Ok so I’m working on a character ai for unity and I have my animations on my game object and the rig is on legacy mode, but for some reason unity keeps giving me an error saying it cant find my animations. I know that the animations are just fine because they’re working in the preview and they were working in game for a little while. I hope someone is able to help me with this cause its a real bummer after taking all of the time to make this character in the first place. Anyway heres my code and a screenshot to show whats going on.
public var PathTarget:Transform;
public var AssignedZone:Transform;
var animController;
var WaitTimer:float;
var State:String;
var IdleAnim:AnimationClip;
private var LocalPathNodeAR:Transform[];
private var MyIndex = 0;
function Start () {
animController = this.GetComponent(Animation);
LocalPathNodeAR = AssignedZone.GetComponent(ZoneSetup).PathAR;
if(PathTarget == null){
BeginWait();
}
}
function FindPaths () {
Debug.Log(LocalPathNodeAR.Length);
MyIndex++;
if(MyIndex>LocalPathNodeAR.Length - 1){
MyIndex = 0;
}
PathTarget = LocalPathNodeAR[MyIndex];
Debug.Log(LocalPathNodeAR);
}
function BeginWait () {
State = "Idle";
WaitTimer = Random.Range(1,3);
}
function Walk () {
State = "Walking";
this.GetComponent(NavMeshAgent).destination = PathTarget.transform.position;
var navmeshAgent = this.GetComponent(NavMeshAgent);
if(navmeshAgent.remainingDistance == 0)
{
BeginWait();
}
}
function Update () {
WaitTimer -= Time.deltaTime;
if(WaitTimer == 0){
FindPaths();
}
switch(State){
case "Idle":
animation.Play(IdleAnim.name);
break;
case "Walking":
animation.Play("MaleBodyWALK");
Walk();
break;
}
}