Hello, i need help to make a UI text element display a float value, i thought i fixed it with help from the internet but it doesnt add 1f for every log i pick up… (every “log” has this script)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PickUpLogs : MonoBehaviour {
private bool InCollider;
public float LogAmount;
public UnityEngine.UI.Text TextLogAmount;
void Start ()
{
TextLogAmount = GameObject.Find ("LogAmountText").GetComponent<UnityEngine.UI.Text>();
}
void Update ()
{
TextLogAmount.text = LogAmount.ToString();
if(InCollider == true)
{
if(Input.GetKeyDown(KeyCode.F))
{
Debug.Log ("Added_1_Log");
LogAmount += 1f;
Destroy(gameObject);
}
}
}
void OnTriggerEnter (Collider col)
{
if (col.tag == "Player")
{
InCollider = true;
}
}
void OnTriggerExit (Collider col)
{
if (col.tag == "Player")
{
InCollider = false;
}
}
}