Created
April 21, 2020 14:07
-
-
Save openroomxyz/4c857eb9c6555bb83daaa31876e8fff8 to your computer and use it in GitHub Desktop.
Unity : How do we destroy gameObject and particle effect on it on destroy?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void KillEnemy() | |
{ | |
ParticleSystem vfx = Instantiate(deathParticlePrefab, transform.position, Quaternion.identity); | |
vfx.Play(); | |
float destroyDelay = vfx.main.duration; | |
Destroy(vfx.gameObject, destroyDelay); | |
//destroy patciles | |
Destroy(gameObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment