- Home /
 
               Question by 
               Seventh Stealth · Dec 27, 2014 at 11:25 PM · 
                javascriptaibooleanstealth  
              
 
              My Object only moves when the variable ready is true. Problem is that ready is only ever true while update is running. So to move the object the variable always has to be true. How can I make it move if the variable ready is false.
 var ready : boolean;
 var speed : float;
 var patrolTimer : float; //how long should it patrol for
 var target1 : Transform;
 
 
 function Update (){
 if(ready ==true){
 Move();
 }
 if(ready == false){
 
 }
 }
 
 
 function Move(){
 Debug.Log("moving");
 
 var step = speed * Time.deltaTime;
 //chooseNext = Random.Range(0,2);
 
         // move towards target
         transform.position = Vector3.MoveTowards(transform.position, target1.position, step);
         
            if(this.gameObject.transform.position == target1.position){
            Patrol();
            Debug.Log("Reached destination");
            
            }
     
 }
 
 
 
 function Patrol(){
 
 Debug.Log("patrolling");
 patrolTimer -= Time.deltaTime;
 
   if(patrolTimer <=0){
              ready = true;
              Debug.Log("Ready to move");
            }
 }
If your confused make a cube and an empty as the target.Set patrol as 7 attach the script to the cube and watch. Ready has to be true for it to move. How can I make the cube move while ready = false; My plan is to add different transforms in that the object can move to later in the project. In case your wondering this is meant to be stealth AI plz help
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by awplays49 · Dec 28, 2014 at 01:07 AM
you need to put the move function under the condition of when it is false
Your answer
 
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Need help with javascript AI 1 Answer
Stealth AI Script. If less than or equal to not working correctly. Any fixes ? 1 Answer
Pause Button Help 2 Answers
ai navigation help 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                