Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cmd+' ctrl+' Input Rigidbody Collider GUI
- using UnityEngine;
- using System.Collections;
- public class PlayerController : MonoBehaviour {
- public float speed;
- private int count;
- 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;
- }
- }
- void OnGUI() {
- GUI.Label (new Rect (10, 10, 100, 20), "Count: " + count);
- if (count >= 12) {
- GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 3, 100, 20), "YOU WIN!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement