I have all of the code I need for the health pickup to drop when I kill an enemy, but I have been working for about 3 days with no luck on how to get it to destroy once it's instantiated. Sorry for the messy wording but here is my code:
function Dead()
{
Instantiate(healthDrop, enemy.transform.position, Quaternion.identity);
gameObject.SetActiveRecursively(false);
}
This is where I am destroying the enemy and instantiating the health drop
#pragma strict
var player : Transform;
var enemy : GameObject;
function Update ()
{
healthDropLogic();
}
var distance = Vector3.Distance(player.transform.position, transform.position);
function healthDropLogic ()
{
yield WaitForSeconds(3);
Destroy(gameObject);
}
This code is on the health drop
#Any help would be much appreciated!
↧