- Home /
variable changes for no reson,this var keeps going down? for no reson?
,if (Vector3.Distance(transform.position , Player.transform.position) <= 0.6)
{
if (knockcount == false)
{
srpt2.Health--;
knockcount = true;
rb.AddForce (Dir.normalized * knockforce * Time.deltaTime ,ForceMode.Impulse);
StartCoroutine("Wait");
}
somthing wierd is happening the health var just keeps going down for seemingly no reson! HELP!
Answer by cszafranski · Jul 26, 2017 at 04:19 PM
So I can't tell for sure but I can see some potential problems with your code. Do a bracket check it seems the first if statement does have a matching '}' which could be due to how you copied in your code. But in general use Debug.Log("My message to print"); to track what is happening in your code. @tytywithasword10
thank you i figured out that the var was going down and activateing wether the requirements of the if statement wher met or not\
Answer by Insurikai_ · Jul 26, 2017 at 04:18 PM
On Line 5 you're making the Health variable of srpt2 subtract 1.
srpt2.Health--;
Your answer

Follow this Question
Related Questions
can't reference variable in script 2 Answers
Script access (without script name) 1 Answer
Variables Not Updating? 1 Answer
Script is setting variables but they're being reset 1 Answer
variables won show up 1 Answer