Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cmd + ' (mac) or ctrl + ' (win) Collider
- 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 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!");
- }
- }
- void OnTriggerEnter(Collider other) {
- if (other.gameObject.tag == "Pickup") {
- other.gameObject.SetActive(false);
- count = count + 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement