Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cmd + ' ctrl + ' Input Rigidbody Collider
- using UnityEngine;
- using System.Collections;
- public class PlayerController : MonoBehaviour {
- public float speed;
- public GUIText countText;
- public GUIText winText;
- private int count;
- // Use this for initialization
- void Awake () {
- count = 0;
- countText.text = count.ToString();
- winText.text = "";
- }
- // Update is called once per frame
- void FixedUpdate () {
- if (Input.GetKey("w")) {
- rigidbody.AddForce (Vector3.forward * speed * Time.deltaTime);
- }
- if (Input.GetKey("s")) {
- rigidbody.AddForce (-Vector3.forward * speed * Time.deltaTime);
- }
- if (Input.GetKey("a")) {
- rigidbody.AddForce (-Vector3.right * speed * Time.deltaTime);
- }
- if (Input.GetKey("d")) {
- rigidbody.AddForce (Vector3.right * speed * Time.deltaTime);
- }
- }
- void OnTriggerEnter(Collider other) {
- if (other.gameObject.tag == "PickUp") {
- other.gameObject.SetActive(false);
- count = count + 1;
- countText.text = count.ToString();
- if (count >= 12) {
- winText.text = "YOU WIN!";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement