Advertisement
LeeMace

Play Effect After Destroying Object

Dec 21st, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EnemyBehaviour : MonoBehaviour
  6. {
  7.     public ParticleSystem explosionParticle;
  8.  
  9.     public void OnTriggerEnter(Collider other)
  10.     {
  11.         if(other.CompareTag("Ground"))
  12.         {
  13. //the following allows particle effect to play after gameobject has been destroyed
  14.             explosionParticle.transform.parent = transform.parent;
  15.             explosionParticle.Play();
  16.             Destroy(gameObject);
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement