how would i limit a mouseclick to 1 so that functions will not repeat with a gajillion mouseclicks? for example, if a player clicks once, a beachball comes onto screen. unfortunately, if you keep clicking, more beachballs come, but there should only ever be the first one. once it's destroyed, a new one can be spawned. any help is appreciated. thanks!
var beachBallPrefab : GameObject;
private var beachBall;
function Update () {
if (!beachBall && Input.GetMouseButtonDown(0)) beachBall = Instantiate(beachBallPrefab);
}
"!beachBall" means there isn't a beach ball in the scene, either because you didn't make one yet, or because you destroyed it.
Add a tag such as BeachballTag and then before instantiating the prefab check the following if statement:
JS:
if(FindGameObjectsWithTag("BeachballTag").length=0)