using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
public Transform prefab;
private Rigidbody rb;
private int count;
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
float jumpers = 0;
if (Input.GetKeyDown (KeyCode.Space))
{
jumpers = 15.0f;
}
Vector3 movement = new Vector3 (moveHorizontal, jumpers, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag("Pickup"))
{
other.gameObject.SetActive (false);
Instantiate (, transform.position, transform.rotation);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = "Count: " + count.ToString ();
if (count >= 49)
{
winText.text = "You win!";
}
}
}
I tried with a private variable isGrounded and used an if statement, yet it still did not work. Can someone give me a hand here, please?
Thanks in advance.