So i have run into an issue of the remains on my destroyed object being duplicated. I have it set up that when the rigid-body is destroyed it spawns a broken apart version of that object, it seems to work fine when i destroy it with damage from ray-casting, but when it is destroyed after the collision velocity it duplicates the remains. Any information is most appreciated.
private void OnCollisionEnter(Collision collision)
{
if(collision.relativeVelocity.magnitude > 10)
{
Die();
}
}
public void TakeDamage (float amount)
{
health -= amount;
if (health <= 0f)
{
Die();
}
}
void Die()
{
Instantiate(remains, transform.position, transform.rotation);
Destroy(gameObject);
}
It seems like it is reading each object collision it touches and keeps creating a new “remains,” is there a way to combat that.