I am using the UI to display the player’s health as text. Whenever the health float has been changed to another value, an extra 0 is added to the end of the player’s health in the text UI ONLY.
For example, if the player took damage and got their health reduced from 100 to 80, the health would display 800 but the Debug.Log would display 80.
This only happens when playing on different resolutions from 1920 x 1080. I am coding in C# so that is preferred.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class PlayerHealth : MonoBehaviour {
float Health;
public Text health;
public GameObject player;
// Use this for initialization
void Start () {
Health = player.GetComponent<MeteorHealth> ().Health;
string healthText = "Health: " + Health;
health.text = healthText;
}
// Update is called once per frame
void Update () {
Health = player.GetComponent<MeteorHealth> ().Health;
string healthText = "Health: " + Health;
health.text = healthText;
}
}