Advertisement
LittleAngel

Untitled

May 22nd, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. // cmd + ' ctrl + ' Input Rigidbody Collider
  2.  
  3. using UnityEngine;
  4. using System.Collections;
  5.  
  6. public class PlayerController : MonoBehaviour {
  7.  
  8. public float speed;
  9. public GUIText countText;
  10. public GUIText winText;
  11. private int count;
  12.  
  13. // Use this for initialization
  14. void Awake () {
  15. count = 0;
  16. countText.text = count.ToString();
  17. winText.text = "";
  18. }
  19.  
  20. // Update is called once per frame
  21. void FixedUpdate () {
  22. if (Input.GetKey("w")) {
  23. rigidbody.AddForce (Vector3.forward * speed * Time.deltaTime);
  24. }
  25. if (Input.GetKey("s")) {
  26. rigidbody.AddForce (-Vector3.forward * speed * Time.deltaTime);
  27. }
  28. if (Input.GetKey("a")) {
  29. rigidbody.AddForce (-Vector3.right * speed * Time.deltaTime);
  30. }
  31. if (Input.GetKey("d")) {
  32. rigidbody.AddForce (Vector3.right * speed * Time.deltaTime);
  33. }
  34. }
  35.  
  36. void OnTriggerEnter(Collider other) {
  37. if (other.gameObject.tag == "PickUp") {
  38. other.gameObject.SetActive(false);
  39. count = count + 1;
  40. countText.text = count.ToString();
  41. if (count >= 12) {
  42. winText.text = "YOU WIN!";
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement