//when any collider trigger the collider of this collectible void OnTriggerEnter(Collider col) { //only carry on if the trigger object is player if (col.gameObject.layer != TDS.GetLayerPlayer()) { return; } //check the effect type and apply them accordingly if (type == _CollectType.Self) //apply effect to player unit { ApplyEffectSelf(col.gameObject.GetComponent <UnitPlayer>()); } else if (type == _CollectType.AOEHostile) //apply effect to all surrounding hostile { ApplyEffectAOE(col); } else if (type == _CollectType.AllHostile) //apply effect to all hostile { ApplyEffectAll(); } else if (type == _CollectType.Ability) { AbilityManager.TriggerAbility(abilityID); } GameControl.ColletibleCollected(this); //play the sound and show spawn the trigger effect object at current position AudioManager.PlaySound(triggerSFX); TriggeredEffect(transform.position + new Vector3(0, 0.1f, 0)); //Destroy(gameObject); ObjectPoolManager.Unspawn(gameObject); }