Hello there, relatively new to unity and c# but right now i’m having a bit of an issue
I have this 3d text object on a “door” object, and said door will slide upward to open when the button right next to it is shot enough times. I want the 3d text’s “Text Mesh” to be the remaining “health” value of the button. How is this done? I tried this–obviously i couldn’t get it to work, i just don’t know why.
here is the script on the button, containing the “health”
public class shootbutton : MonoBehaviour
{
public static float health = 600;
public float bulletdamage = 1;
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "bullet")
{
health = health - bulletdamage;
}
}
}
and here is the nonfunctioning script for my 3d text object
public class scorereport : MonoBehaviour {
void Update () {
GetComponent.TextMesh().text = FindObjectOfType<bulletbehavior>().health;
}
}