Advertisement
LittleAngel

Untitled

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