I'm making a simple game using Unity where the player needs to pick up coins as much as possible. When the player hits the coin, the coin will disappear and the score will be incremented, for example by 1, here's my script
#pragma strict
var coinEffect : Transform;
var coinValue = 2;
function OnTriggerEnter (info : Collider) {
if (info.tag == "Player") {
// Debug.Log("Ball is picked up");
var effect = Instantiate(coinEffect, transform.position, transform.rotation);
GameMaster.currentScore += coinValue;
Debug.Log(coinValue);
};
}
The problem is the variable coinValue
is printed 0 when I print it to the console.
Any idea Why?
UPDATE i don't know why but if i declare another varible for example number
= 12 and printed it.. It's working. But maybe this is a really strange case with the variable name.. I Don't Know.. Maybe, just maybe there is a flaw in their program for this varible name
Because you are using unityscript (not javascipt) the variable defined out side of the functions is set within the inspector
view of the unity. Changes in the code to the initial values of these variables don't affect to values that are set from the inspector
.
Select the GameObject you have attached the script to and find the script in the inspector
view. There you can see the variable.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다