unity 3d student

Beginner B27 – Using Time.timeScale to Pause

How to Pause the game by implementing Time.timeScale.

Code Used (Javascript)

  1. var paused : boolean = false;
  2.  
  3. function Update () {
  4.  if(Input.GetButtonUp("Jump")){
  5.   if(!paused){
  6.    Time.timeScale = 0;
  7.    paused=true;
  8.   }else{
  9.    Time.timeScale = 1;
  10.    paused=false;
  11.   }
  12.  }
  13. }

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

27 Comments