Debug.Log printing 2 values
I'm creating a health bar program. The part that I am having a problem with is this. I am dividing the current health and the initial health. Then I display this with debug.log. I consistently get two answers every frame: the correct answer, followed by the same incorrect answer, which is 1.
For example,
0.9 1 0.5 1 0.4 1 0.25 1
Here is my script (cut the parts unrelated to the problem):
public float health;
private float initialHealth;
void Start()
{
initialHealth = health;
}
void Update()
{
Debug.Log(health / initialHealth);
}
I think this is your problem:
Here is my script (cut the parts unrelated to the problem):
Post full script and someone might help
Answer by tormentoarmagedoom · Jul 11, 2018 at 06:42 AM
Good day.
With the code you posted, there is no problem.
You will get a Debug.Log every frame.
If you recieve 2 messages per frame, it means you have 2 scripts doing the same.
Bye,