Question by
YMbrothers · Dec 12, 2015 at 03:09 AM ·
javascriptkeycodestatic variableclass object
static class not functioning
So, I got his code:
#pragma strict
public class Charge {
public static var charge_time : int = 2;
function Update()
{
print (charge_time);
if (Input.GetKey(KeyCode.Space)){
charge_time --;
}
if (Input.GetKeyUp(KeyCode.Space)) {
charge_time = 2;}
}
}
The problem is: I tried this thing, and it seems that the variabe "charge_time" didn't change its value, this thing didn't ever print anything at all,
I tried the print in other scripts, the script prints it successfully, but the value appeared to be remain unchanged. I think the problem is that
if (Input.GetKey(KeyCode.Space)){
charge_time --;}
is not functioning nor functioning in a loop.
I wish for another reply for the noob standing here.
Comment
Your answer
Follow this Question
Related Questions
Change of Scene 1 Answer
static failure 0 Answers
How get position from a game object? 5 Answers