I am instantiating a box so that it appears when I kill an enemy. I am using this code to check to see if I am close to the box; if I am then the box will be destroyed. My only problem is that I don’t know how to set healthDrop to the object I’m instantiating.
function Update ()
{
if (healthDrop)
{
var distance = Vector3.Distance(healthDrop.position, transform.position);
if (distance < 2)
{
Destroy("healthDrop")
}
}
}