Hello, I need your help!!, I´m having trouble with te following script:
//Inspector Variables
var shapeColor : Color[ ];
var respawnWaitTime :float=2.0f;
var posx:float;
var posy:float;
var Shpere:GameObject;
function Start()
{
//Set a GameObject on an initial position and give a color
var position=Vector3 (posx,posy,0);
transform.position=position;
RandomColor();
}
function MakeBox(){
//Store an initial position
var position=Vector3 (posx,posy,0);
//Wait some seconds before create a new box
RespawnWaitTime();
//Create a new Box with an initial position
Instantiate(Box,position,transform.rotation);
}
function OnTriggerEnter (myTrigger : Collider) {
//If a collision with specific object occurs
if(myTrigger.gameObject.name == “me”){
//Destroy this gameObject
Destroy(gameObject);
//Call MakeBox
MakeBox();
}
}
function RespawnWaitTime()
{
//Call function to change the color
RandomColor();
//Wait for 3 seconds
yield WaitForSeconds(3);
}
function RandomColor()
{
//Check if there are an arrey with colors
if(shapeColor.Length>0)
{
//Assign a new color
var newColor=Random.Range(0,shapeColor.Length);
renderer.material.color=shapeColor[newColor];
}
}
The problem is that the function RespawnWaitTime() doesn´t works… I tried in different ways but with any results. somebody knows which is the problem??
Thanks,