Advertisement
LittleAngel

Untitled

Jul 22nd, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // cmd + ' (mac) or ctrl + ' (win) Collider
  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 OnGUI () {
  27. GUI.Label(new Rect(10, 10, 100, 20), "Count: " + count);
  28. if (count >= 12) {
  29. GUI.Label (new Rect(Screen.width / 2 - 50, Screen.height / 3, 100, 20), "YOU WIN!");
  30. }
  31. }
  32.  
  33. void OnTriggerEnter(Collider other) {
  34. if (other.gameObject.tag == "Pickup") {
  35. other.gameObject.SetActive(false);
  36. count = count + 1;
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement