Advertisement
LittleAngel

Untitled

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