Another "destructive" solution

In Projectile.cs I have put Destroy(gameObject, 5.0f); in Start() method.

Also in OnTriggerEnter method

        if (hitEffect != null)
        {
            GameObject effect = Instantiate(hitEffect, GetAimLocation(), transform.rotation);
            Destroy(effect, 5.0f);
        }
1 Like

you can add a mesh render to the projectile parent and use this instead of destroying after 5 seconds.
private void OnBecameInvisible()

    {
        // Destroy the projectile when it becomes invisible
        Destroy(gameObject);
    }

Privacy & Terms