Major problem here. I am making a looting system. I may have to re-write it if this doesn’t help. I am totally stumped on this one. I got the player to kill the enemy and instantiate the pouch, however, I don’t know how to get it to destroy!!! I’ve tried GameObject.Find();, but that doesn’t work because I have multiple objects. I also don’t want to make individual prefabs, and also GameObject.Find(); cant find inactive objects. How dumb is that?!
Here is the collection piece:
#pragma strict
var minExp : float;
var maxExp : float;
var minGold : float;
var maxGold : float;
var hud : GameObject;
private var gold : int;
private var exp : int;
var expGui : GameObject;
var goldGui : GameObject;
function Start () {
exp = Random.Range(minExp, maxExp);
gold = Random.Range(minGold, maxGold);
hud = GameObject.Find("Loot Pouch");
expGui = GameObject.Find("exp");
goldGui = GameObject.Find("gold");
}
function OnTriggerStay (col : Collider) {
if(col.gameObject.tag == "Player" && Input.GetKeyDown(KeyCode.E)) {
hud.active = true;
expGui.guiText.text = "EXP: " + exp;
goldGui.guiText.text = "GOLD: " + gold;
}
}
Here is the take:
#pragma strict
var lootHud : GameObject;
function Start () {
lootHud = GameObject.Find("Loot Pouch Hud");
}
function OnMouseEnter () {
guiText.color = Color.red;
}
function OnMouseExit () {
guiText.color = Color.blue;
}
function OnMouseDown () {
lootHud.active = false;
}