Advertisement
LittleAngel

Untitled

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