Hi guys,
So ive managed to make my script work this far, but now im stuck at this last part.
Basically what i want to do is make the item respawn after you pick it up.
As you can tell by my commented out code ive already tried to get it to work myself but im all out of ideas on how to make this work in the most simple way.
Heres my script:
public var timer : float = 3;
private var Items : int;
public var SpawnPosition : GameObject;
public var canpickup : boolean = true;
public var Item1 : GameObject;
public var Item2 : GameObject;
public var Item3 : GameObject;
public var Item4 : GameObject;
public var Item5 : GameObject;
function Start()
{
timer = 3;
canpickup = false;
Items = Random.Range(1,5);
}
function Update ()
{
if(canpickup == false)
{
timer = timer - Time.deltaTime;
{
if (timer <= 0)
{
if (timer == 0);
if (Items == 1)
{
Instantiate(Item1, SpawnPosition.transform.position, SpawnPosition.transform.rotation);
canpickup = true;
timer = 3f;
}
else
{
//(Item1 == null);
canpickup = true;
}
if (Items == 2)
{
Instantiate(Item2, SpawnPosition.transform.position, SpawnPosition.transform.rotation);
canpickup = true;
timer = 3f;
}
else
{
//(Item2 == null);
canpickup = true;
}
if (Items == 3)
{
Instantiate(Item3, SpawnPosition.transform.position, SpawnPosition.transform.rotation);
canpickup = true;
timer = 3f;
}
else
{
//(Item3 == null);
canpickup = true;
}
if (Items == 4)
{
Instantiate(Item3, SpawnPosition.transform.position, SpawnPosition.transform.rotation);
canpickup = true;
timer = 3f;
}
else
{
//(Item4 == null);
canpickup = true;
}
if (Items == 5)
{
Instantiate(Item5, SpawnPosition.transform.position, SpawnPosition.transform.rotation);
canpickup = true;
timer = 3f;
}
else
{
//(Item5 == null);
canpickup = true;
}
}
}
}
}