- Home /
 
               Question by 
               diversity12 · Oct 08, 2014 at 02:47 PM · 
                javascriptvector3randommoveempty game object  
              
 
              Move empty object random
I have to move an empty object every 3 seconds randomly within a defined area. to do this, I created this script:
pragma strict
var Spaw: GameObject;
function Start () {
}
function Update () {
transform.position = new Vector3 (Random.Range (-25.0f, 25.0f, 0.0f, 130.0f, 135.0f));
}
But it does not work. where did I go wrong?
               Comment
              
 
               
              Answer by MrSoad · Oct 12, 2014 at 11:14 AM
Here is a more complete answer for you now I have a bit more time.
 function Start () {
 
     //The "0" say to start this right now. The "3" says to repeat this every three seconds.
     InvokeRepeating("subMove_Object", 0, 3);
 }
 
 function subMove_Object() {
 
     transform.position = Vector3((Random.Range(-25.0, 25.0), 0.0, Random.Range(130.0, 135.0));
 }
Your answer
 
 
             Follow this Question
Related Questions
Vector3.lerp doesn't work 1 Answer
CharacterController Gravity 2 Answers
How to move an object around with the arrow keys (Javascript) 1 Answer
Moving rigidbodies at random 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                