- Home /
TextMesh isn't updating itself.
Hi, i am new to Unity and trying to make some simple projects to learn it. I want to update textmesh.text everytime when i clicked my gameobject.
i guess this code should do the trick but it doesnt work.
hptclone.GetComponent<TextMesh>().text=counter.ToString();
void Update () {
TimeChange();
if(control==true)
{
hptclone.GetComponent<TextMesh>().text=hp.ToString();
counter=hp;
Spawner(enemyclone, hptclone);
control=false;
}
if(Input.GetMouseButtonDown(0))
{
if(GameObject.FindGameObjectWithTag("enemy"))
{
counter--;
hptclone.GetComponent<TextMesh>().text=counter.ToString();
print(counter);
if(counter==0)
{
score+=10;
Destroy(hpt);
Destroy(enemy);
hp++;
control=true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
c# how to refresh my targeting list 2 Answers
Alarm lights not changing 1 Answer
What is way to flash the screen WITHOUT using a Texture? 2 Answers
Photon Networking Prefab help 0 Answers