using UnityEngine; [RequireComponent(typeof(Collider))] public class ChaseCoin : MonoBehaviour { public int coinValue = 1; private void Reset() { // ensure trigger var col = GetComponent(); if (col) col.isTrigger = true; } private void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) return; // 1) Spawn VFX via ancestor spawner (works even if the adder is many parents up) var vfxAdder = GetComponentInParent(); if (vfxAdder) vfxAdder.SpawnAt(transform); // 2) Score var scoreMgr = FindObjectOfType(); if (scoreMgr) scoreMgr.AddScore(coinValue); // 3) Destroy coin Destroy(gameObject); } }