public Text Damagew;
void Start () {
anim = GetComponent<Animator> ();
Damagew.enabled = false;
}
public void AppliedDamage(float damage){
health -= damage;
if (health <= 0f) {
anim.Play("Death");
Destroy (gameObject,2);
Damagew.enabled = true;
}
}
Hello @Arin_Jisoo !!
Then you need this:
Have a Text with " Zombie Kill ! " and use the “enabled” attribute to show/not show. You can also use the “Invoke” to send the command “stop showing the text in 1 second”.
Lets call the Text Object TheTextYouWantToShow in the GameScene. Then, we need to declare and identify it in the script:
Text KillZmbText;
private void Start ()
{
KillZmbText = GameObject.Find ("TheTextYouWantToShow").GetComponent<Text>();
}
Now, lets create a method that will stop showing the text
void StopShowingZombieText()
{
KillZmbText.enabled=false;
}
Now we need to create the commands that will show the text, and will program for 1 second later the method “StopShowingZombieText”. Put this in the script where will be executed when a zombie is killed:
KillZmbText.enabled=true;
Invoke ("StopShowingZombieText",1);
As you can imagine, the invoke calls a method writed as string (so is not possible to use methods with parameters) in a selected time (in float, you can use decimals like 1.5f or 8.256435f) :
Invoke (“Nameofmethod”, time in seconds)
I think i solved your problem, if not, ask for more using @tormentoarmagedoom
Bye!
This is my code. what i want to happen if. is the death animation play. the UI text shows with “Kill Zombie” and that’s happen. but my problem is it not disappear what i want if after 1 seconds my text will be disappear and show up again when i kill another zombie. thanks for help