I do not understand how this function works. The script is without error but I would like to make this script work. It does not create the object when it reaches the limit
var ScoreS : ScoreScript;
var Activate : boolean;
var Spawner : GameObject;
var SpawnObj : GameObject;
function Update(){
var Score : int;
for(var i:int =0; i < Input.touches.Length; i++){
var touch:Touch=Input.touches[i];
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
var hit:RaycastHit =new RaycastHit ();
if(Physics.Raycast(ray,hit,1000)){
if(hit.collider.gameObject ==this.gameObject){
switch(touch.phase){
case TouchPhase.Began:
Score += 1;
break;
}
}
}
}
if(Score == 10){
Activate = true;
}
if(Activate == true){
Instantiate(SpawnObj,Spawner.transform.position,Spawner.transform.rotation);
Score = 0;
Activate = false;
}
}
↧