Advertisement
LittleAngel

Untitled

May 13th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 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.  
  8. public float speed;
  9. private int count;
  10.  
  11. void Awake () {
  12. count = 0;
  13. }
  14.  
  15. // Update is called once per frame
  16. void FixedUpdate () {
  17. if (Input.GetKey("w")) {
  18. rigidbody.AddForce (Vector3.forward * speed * Time.deltaTime);
  19. }
  20. if (Input.GetKey("s")) {
  21. rigidbody.AddForce (-Vector3.forward * speed * Time.deltaTime);
  22. }
  23. if (Input.GetKey("a")) {
  24. rigidbody.AddForce (-Vector3.right * speed * Time.deltaTime);
  25. }
  26. if (Input.GetKey("d")) {
  27. rigidbody.AddForce (Vector3.right * speed * Time.deltaTime);
  28. }
  29. }
  30.  
  31. void OnTriggerEnter(Collider other) {
  32. if (other.gameObject.tag == "PickUp") {
  33. other.gameObject.SetActive (false);
  34. count = count + 1;
  35. }
  36. }
  37.  
  38. void OnGUI() {
  39. GUI.Label(new Rect(10, 10, 100, 20), "Count: " + count);
  40. if (count >= 12) {
  41. GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 3, 100, 20), "YOU WIN!");
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement