Advertisement
LittleAngel

Untitled

Jun 17th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // cmd + '(mac) / ctrl + '(win) Collider
  2.  
  3. using UnityEngine;
  4. using System.Collections;
  5.  
  6. public class PlayerController : MonoBehaviour {
  7.  
  8. public float speed;
  9. public string myString = "Default";
  10. private int count;
  11.  
  12. void Awake () {
  13. count = 0;
  14. myString = "Set in Awake!";
  15. }
  16.  
  17. void FixedUpdate () {
  18. if (Input.GetKey("w")) {
  19. rigidbody.AddForce (Vector3.forward * speed * Time.deltaTime);
  20. }
  21. if (Input.GetKey("s")) {
  22. rigidbody.AddForce (-Vector3.forward * speed * Time.deltaTime);
  23. }
  24. if (Input.GetKey("a")) {
  25. rigidbody.AddForce (-Vector3.right * speed * Time.deltaTime);
  26. }
  27. if (Input.GetKey("d")) {
  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