using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Pool; public class Body : MonoBehaviour { private ObjectPool m_Pool; public Transform m_Pelvis; public int m_DespawnTimer; private void OnEnable() { StartCoroutine(DespawnTimer()); } public void SetPool(ObjectPool pool) { m_Pool = pool; } IEnumerator DespawnTimer() { yield return new WaitForSecondsRealtime(m_DespawnTimer); m_Pool.Release(this); } }