I’m triggering an animation that plays when the Enemy mesh is colliding with a Projectile mesh that is tagged.
The animation should play where the “Enemy” location is.
The script is attached to the Enemy.
The game object that has the animation is a 3DText mesh made into a prefab.
The animation plays but does not disappear.
How can I destroy the prefab (that plays the animation)?
If I do: Destroy(gameObject) it will destroy the Enemy only.
Do I need to set a clone for the prefab? And destroy the clone?
Thanx Guys!
public class Bonus_Animation : MonoBehaviour
{
//GameObject with the bonus animation attached
GameObject spawnBonus;
//bonus points at 50
public int points = 50;
void OnCollisionEnter (Collision col)
{
if(col.transform.tag == "Projectile")
{
Instantiate(spawnBonus, transform.position, transform.rotation);
}
}
}