- Home /
Question by
bvincearthur1 · Apr 18, 2018 at 03:25 AM ·
button trigger events
I want my enemy object to take damage when a button is clicked, how?
This is my enemy health script.
public const int maxHealth = 100; public int currentHealth = maxHealth;
public void TakeDamage (int amount)
{
currentHealth -= amount;
if (currentHealth <= 0)
{
currentHealth = 0;
Debug.Log("Dead!");
}
}
Comment
Your answer
Follow this Question
Related Questions
particle system stop and play right after clicking a button 0 Answers
Adding Functions to GUI Buttons? 1 Answer
I am trying to make game objects to click to go to another scene 0 Answers
Creating a Jeopardy style game, script's not working. 0 Answers
Need some help with Object movement on Button press !!. 1 Answer