Quantcast
Viewing latest article 11
Browse Latest Browse All 90

Answer by doomprodigy

Unsure on what the cause is, though make it go

function Update(){

   if(isRunning == true)    
  {        
  animation.CrossFade("run");    
  }    

  else if(isRunning == false)
  {        
    animation.CrossFade("Take 001");    
  } 

  var distanceToTarget = Vector3.Distance(transform.position, target.position);    
  if(distanceToTarget <= stopRange)    
  {        
  isRunning = false;       
  animation.CrossFade("Take 001");    
  }
}

That way it does either run or not.

(Unsure if it fixes your problem).

May I also add that when I script AI functions use a finte state machine. Or just use states/cases inside the same script.

Example:

enum animals {    
dog,    
cat,    
bird
}

function Start(){    
var animals : animals = animals.dog;    

switch(choice)    {        
case animals.dog:            
 Debug.Log("dog");            
break;        
case animals.cat:           
 Debug.Log("cat");            
break;        
case animal.bird:            
Debug.Log("bird");            
break;        
default:            
Debug.Log("nothing");           
break;    
}

Peace, Aaron Lewis


Viewing latest article 11
Browse Latest Browse All 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>