Advertisement
LittleAngel

Untitled

Jan 21st, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. // cmd+' ctrl+' Input Rigidbody Collider GUI
  2.  
  3. using UnityEngine;
  4. using System.Collections;
  5.  
  6. public class PlayerController : MonoBehaviour {
  7. public float speed;
  8. private int count;
  9.  
  10. void FixedUpdate () {
  11. if (Input.GetKey("w")) rigidbody.AddForce (Vector3.forward * speed * Time.deltaTime);
  12. if (Input.GetKey("s")) rigidbody.AddForce (-Vector3.forward * speed * Time.deltaTime);
  13. if (Input.GetKey("a")) rigidbody.AddForce (-Vector3.right * speed * Time.deltaTime);
  14. if (Input.GetKey("d")) rigidbody.AddForce (Vector3.right * speed * Time.deltaTime);
  15. }
  16.  
  17. void OnTriggerEnter (Collider other) {
  18. if (other.gameObject.tag == "PickUp") {
  19. other.gameObject.SetActive (false);
  20. count = count + 1;
  21. }
  22. }
  23.  
  24. void OnGUI() {
  25. GUI.Label (new Rect (10, 10, 100, 20), "Count: " + count);
  26. if (count >= 12) {
  27. GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 3, 100, 20), "YOU WIN!");
  28. }
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement