Advertisement
MrsMcLead

Movement with Timer

Oct 22nd, 2014
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.     var count : int;
  3.     var countText : GUIText;
  4.     var winText : GUIText;
  5.     var jumpheight : float;
  6.     var myTimer : float = 5.0;
  7.     var display : GUIText;
  8.    
  9.    
  10.    
  11. function Start()
  12. {
  13.     count = 0;
  14.     countText.text = "Counter: " + count.ToString();
  15.     winText.text = " ";
  16. }
  17.  
  18. function FixedUpdate () {
  19.     var horizontal : float = Input.GetAxis("Horizontal");
  20.     var vertical : float = Input.GetAxis("Vertical");
  21.    
  22.     var speed : float = 3;
  23.    
  24.  
  25.     rigidbody.AddForce(Vector3(horizontal*speed,0,vertical*speed));
  26.    
  27.     if (Input.GetButton("Jump")) {
  28.         Jump();
  29.     }
  30.     if(myTimer > 0){
  31.         myTimer -= Time.deltaTime;
  32.         var postedTime = Mathf.Floor(myTimer);
  33.          display.text = "Time Remaining: " + postedTime;
  34.     }
  35.     if(myTimer <= 0){
  36.         //do something!
  37.     }
  38.    
  39.  }
  40.  
  41. // Destroy everything that enters the trigger
  42.  
  43.  
  44. function Jump() {
  45.    
  46.         rigidbody.AddForce(Vector3.up * jumpheight);
  47.        
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement