UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"Kill the 2d enemy in platformer game"
public class KillEnemy : MonoBehaviour { [SerializeField] GameObject enemy; [SerializeField] AudioClip sound; private void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.CompareTag("PlayerFeet")) { AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position); enemy.tag = "Untagged"; FindObjectOfType<VFXCtrl>().ShowEnemySparkle(collision.gameObject.transform.position); Destroy(enemy); } } }