[CLOSED] How could i use 2 or more Prefabbed .FBX model animations in my "Chase Player" Script?

this is a small problem i am encountering but can’t seem to find the right way to do it.

at the current moment i have two animations that i have prefabbed called “deathStalkerIdle” and “deathStalkerRun” each prefab is a rigged model of the AI.

when my player comes into range the model, it will advance towards the player and when a certain length away, it will stop.

to the point: Play the running prefab animation when player is in range. and play idle prefab animation when player is not.

this is a script i found on the unity forum, which is much better than the one i did.
I forgot who wrote this, but i will give them credit for the script.

// This is the object to follow

var leader : Transform; 
// This is the object which follows
var follower : Transform; 
// This is the speed with which the follower will pursue
var speed : float = 2.0;
// This is the range at which to pursue
var chaseRange : float = 10.0;
// This is used to store the distance between the two objects.
private var range : float; 

var runPrefab : Rigidbody;

function Update(){ 

   // Calculate the distance between the follower and the leader.

   range = Vector3.Distance( follower.position,leader.position );

   if ( range <= chaseRange )
   {
      // If the follower is close enough to the leader, then chase!
      
      follower.LookAt(leader); 
      follower.Translate( speed * Vector3.forward * Time.deltaTime); 

 

   } // End if (range <= chaseRange) 

    

   else { 

 

      // The follower is out of range. Do nothing.

      return;

 

   } // End else (if ( range <= chaseRange ))

 

} // End function Update()

if anyone has any ideas on how i can do this, i will greatly appreciate it.

Thanks

  • Ownerfate

Good god, i forgot about this … beast of a horrid script…

i scrapped that whole system and brought in one that was MUCH smoother and doesn’t include prefabbing.