public void FixedUpdate() { if (healthReference <= 0) { BaseAgent baseAgent = GetComponent <BaseAgent>(); if (baseAgent != null) { baseAgent.EndEpisode(); GameObject.Destroy(gameObject, Time.fixedDeltaTime); } else { GameObject.Destroy(gameObject); } } }