Advertisement
MrsMcLead

SphereMovement/Control

Oct 10th, 2014
464
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.  
  7.    
  8.    
  9. function Start()
  10. {
  11.     count = 0;
  12.     countText.text = "Counter: " + count.ToString();
  13.     winText.text = " ";
  14. }
  15.  
  16. function FixedUpdate () {
  17.     var horizontal : float = Input.GetAxis("Horizontal");
  18.     var vertical : float = Input.GetAxis("Vertical");
  19.    
  20.     var speed : float = 3;
  21.    
  22.  
  23.     rigidbody.AddForce(Vector3(horizontal*speed,0,vertical*speed));
  24.    
  25.     if (Input.GetButton("Jump")) {
  26.         Jump();
  27.     }
  28.    
  29.  }
  30.  
  31. // Destroy everything that enters the trigger
  32. function OnTriggerEnter (other : Collider) {
  33.     if(other.gameObject.tag== "Pickup")
  34.         other.gameObject.SetActive(false);
  35.         count++;
  36.         countText.text = "Counter: " + count.ToString();
  37.         if(count >= 8)
  38.         {
  39.             winText.text="You Win!";
  40.             yield WaitForSeconds(3);
  41.             Application.LoadLevel("level2");
  42.             }
  43. }
  44.  
  45. function Jump() {
  46.    
  47.         rigidbody.AddForce(Vector3.up * jumpheight);
  48.        
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement