I have a script written,
where my player will destroy an enemy and cause it to disappear. But i’m trying to instantiate another
game object afterwards. Does anyone have suggestions?
This is what I have so far:
The spirit variable above is the sphere that i’m trying to instantiate.
On a side note, this is the health script I have attached to the enemy. I’m hoping that I’m at least using the right logic about where I need to place the instantiate?
Not sure why you’re creating the spirit G/O when it collides with things by using OnTriggerEnter?
But anyways, this is what you need.
//Also up top, var spirit needs to be a GameObject not a transform.
var spirit : GameObject;
/.....
//Change your current if statement block to
if( hitPoints < 1 ) { //Also I would change this to, hitPoints <=0, so it's only when he is truly dead.
var spirit = Instantiate(spirit, gameObject.transform.position, Quaternion.identity);
Destroy(gameObject, 0.0);
}