i want to spawn a certain amount each time
var health : int;
var details : boolean = false;
//this is the amount i want it to spawn but i wanna be able 2 change it
var amount = 1;
var Item;
var item1 : GameObject;
var item2 : GameObject;
var item : Transform;
var damage : float = 5;
var itemname = "Stone";
var level : int;
function Start ()
{
level = Random.Range(1, 10);
health = hitcount * level * 10;
}
function Update()
{
if(hit)
{
health -= (Random.Range(0, 100));
hit = false;
}
if(health <= 0)
{
if (Random.value <= 0.5)
{
Item = item1;
}
else
{
Item = item2;
}
//need to set the amount here but unsure of how
Instantiate(Item, item.position, Quaternion.identity);
Destroy(this.gameObject);
}
}
function OnGUI()
{
if(details)
{
GUI.Box(Rect(0, 0, 100, 75), itemname);
GUI.Box(Rect(0, 25, 100, 25), level.ToString());
GUI.Box(Rect(0, 50, 100, 25), health.ToString());
}
}
function OnTriggerEnter(other : Collider)
{
if(other.tag == "item1")
{
hit = true;
}
if(other.tag == "item2")
{
details = true;
}
}
function OnTriggerExit(other : Collider)
{
if(other.tag == "item2")
{
details = false;
}
}
↧