if 으로 변수의 값을 어떻게 바꾸나요 c#
조회수 708회
if (Input.GetKeyDown(KeyCode.DownArrow)) {
int current_health = 10;
current_health += 30;
Debug.Log("회복물약 사용됨" +current_health);
}
누르면 누를수록 피도 같이 올리고싶은데
10
40
70
100
이런식으로 하고싶은데 이렇게는 그냥 많이 눌러도 10 + 30
인 40
만 자꾸나와요
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
int current_health = 10; if (Input.GetKeyDown(KeyCode.DownArrow)) { current_health += 30; Debug.Log("회복물약 사용됨" +current_health); }
이런식으로 current_health를 초기화 하는 문장을 if문 밖에서 선언하시면 될것같습니다.
-
(•́ ✖ •̀)
알 수 없는 사용자
-
댓글 입력