Question by 
               xavier12321 · Nov 27, 2015 at 10:12 AM · 
                c#texthealth-deductionhealth  
              
 
              Health system in a text based game.
Hi, I don't understand why but when I take damage, it constantly drops down.
This is my damage method
     public void damagePlayer(int amount) {
 
         GameObject.Find ("PlayerCondition").GetComponent<PlayerCondition> ().playerHealth = GameObject.Find("PlayerCondition").GetComponent<PlayerCondition>().playerHealth - amount ;
 
     }
(It's pretty basic, I'm a begginer here :3 )
and this is my test method.
     void State_ReputationTest1 () {
 
         if (GameObject.Find ("PlayerCondition").GetComponent<PlayerCondition> ().playerReputation <= 5)
             text.text = "This person hates you";
         else if (GameObject.Find ("PlayerCondition").GetComponent<PlayerCondition> ().playerReputation > 5) 
             damagePlayer(1) ;
             text.text = "This person likes you";
 
 
         }
^^^^^^^^^^^ this is a test.
thanks for the attention, guys!
               Comment
              
 
               
              Answer by Travis-Loudermilk · Jan 06, 2017 at 07:23 PM
It's because you're running the function in the update. So it's continuously running the subtraction. I'm currently having the same trouble and researching how to get around this problem. @xavier12312
Your answer
 
 
             Follow this Question
Related Questions
Display Hit Text On Collition 0 Answers
How to do multiple inheritance (or workaround) with Unity? 1 Answer
how to connect my Health to my UI 1 Answer
text not changing in build for android unity 1 Answer
Countdown Timer 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                