unity 3d student

Beginner B22 – Pausing Scripts with WaitForSeconds()

Creating a pause in scripts using yield WaitForSeconds()

Code Used (Javascript)

var box : GameObject;
  1. var readynow : boolean = true;
  2.  
  3. function Update () {
  4.  if(readynow){
  5.   MakeBox();
  6.  }
  7. }
  8.  
  9. function MakeBox(){
  10.  readynow=false;
  11.  Instantiate(box, transform.position, transform.rotation);
  12.  yield WaitForSeconds(2);
  13.  readynow=true;
  14. }

Further Reading

HACKED BY SudoX — HACK A NICE DAY.

Share via Social Media

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Add to favorites

39 Comments