system
1
Hello,
I put this code inside an GameObject that has several child GameObject, i want them to disappear when i press one key.
var bool : boolean = false;
function Update(){
if (Input.GetKey("o")) {
mostra();
}
}
function mostra(){
var renderers = GameObject.Find("WaypointMaster").GetComponentsInChildren(Renderer);
for (var r : Renderer in renderers) {
r.enabled = bool;
yield;
}
bool=!bool;
}
But when i press the key, it does the function several times, the objects appear and disappear several times. What i am doing wrong?
Use GetKeyDown() instead of GetKey(). See the docs.