private void OnRoboCarDestroyed(RoboCar roboCar) { roboCar.DestroyedAction -= OnRoboCarDestroyed; //Return the object back to the pool componentPool.ReturnObject(roboCar); }
protected override void Spawn() { RoboCar roboCar = componentPool.GetObject() as RoboCar; Transform spawnTransform = GetSpawnLocation(); roboCar.transform.position = spawnTransform.position; Vector3 targetPosition = spawnTransform.position; targetPosition.z = TARGET_Z_POS; roboCar.Initialize(potatoPile, spawnTransform, targetPosition); roboCar.DestroyedAction += OnRoboCarDestroyed; roboCar.gameObject.SetActive(true); }