- Home /
 
Shoot Delay Problem[HELP]
Hi I am doing 2d maze game. I have an material(it stay fixed point in terrain) which is must shoot a sphare. I created sphare and put it front of the material and unclick Mesh Renderer. After that I added the scipt: var projectile : Transform;
 var bulletSpeed : float = 20;
 
  
 
 function Update () {
 
  
 
     var clone : Transform;
 
     clone = Instantiate(projectile, transform.position, transform.rotation);
 
     clone.rigidbody.AddForce(clone.transform.forward * 5000);
 }
 
               Next add Roll in a Ball in Projectile. It fired continuously but I need delay for it. material must fire each 3 second. I tried it with a lot of ready scripts but i can not it. I am new user. Please help me. Thank you.
Answer by phant0mm · Dec 25, 2012 at 11:14 PM
I can do it. Thank you...
 var projectile : Transform;
 var bulletSpeed : float = 20;
 var delay = 200;
 
 function Start () {
 
     while (true) {
     var clone : Transform;
     clone = Instantiate(projectile, transform.position, transform.rotation);
     clone.rigidbody.AddForce(clone.transform.forward * 5000);    
     yield WaitForSeconds(delay);
 }
   
 }
 
              Your answer
 
             Follow this Question
Related Questions
How to put a pause in a function? 3 Answers
Problem with enemy shooting 4 Answers
How to make a gun shoot in burst. 2 Answers
Slowing down the speed of my bullets whilst holding in the key. 1 Answer
How to add a delay to my script. 3 Answers