Advertisement
LittleAngel

Untitled

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