if (Input.GetKeyDown(KeyCode.DownArrow)) {
int current_health = 10;
current_health += 30;
Debug.Log ("Recovery Potion Used" +current_health);
}
The more I press it, the more I want to raise the blood.
10
40
70
100
I want to do it like this, but even if I press it a lot, only 10 + 30
40 keeps coming out.
int current_health = 10;
if (Input.GetKeyDown(KeyCode.DownArrow)) {
current_health += 30;
Debug.Log ("Recovery Potion Used" +current_health);
}
In this way, you can declare the sentence that initializes current_health outside the if statement.
© 2024 OneMinuteCode. All rights reserved.