Hi guys, my first question on here, I’ trying to build a game where a cylinder rotates around and when it complete a rotation it adds 1 to the score. I tried doing this by adding a cube into the scene with the following script, so that when the cylinder collides with the cube it adds one to the score.
var scoreText: GUIText;
private var score : int;
var counter: GameObject;
function Start(){
//counter2 = GameObject.Find("Score");
score = 0;
UpdateScore();
}
// Destroy everything that enters the trigger
function OnTriggerEnter ( Collider ) {
if(gameObject.tag == "Pick")
//for (var x = 0; x > 1; x++){
collider.enabled = true;
Instantiate(counter, Vector3(42.50991, 5.041063, 34.19414), Quaternion.identity);
Destroy(counter);
score = score + 1;
UpdateScore();
// }
}
function UpdateScore (){
scoreText.text ="Count: " + score;
}
The problem I’m having is that when the cube is instantiated it loses it collision and stops adding to the score. Any help would be appreciate, been trying to do this for a couple of days.