// Method to initialize the plant behaviour private void initializePlant() { objectPooler.spawnFromPool(plantModels[currentState].name, transform.position, transform.rotation, out currentPlant); plantHealthScript = currentPlant.GetComponent <Plant_Health_Logic>(); currentPlant.transform.parent = this.gameObject.transform; currentPoints = pointsPerState[currentState]; plantHealth = Health; }
// Method to change the model of the plant private void updateModel() { currentPlant.transform.parent = null; objectPooler.killGameObject(currentPlant); currentState++; objectPooler.spawnFromPool(plantModels[currentState].name, transform.position, transform.rotation, out currentPlant); plantHealthScript = currentPlant.GetComponent <Plant_Health_Logic>(); plantHealthScript.updateHealth(plantHealth); currentPlant.transform.parent = this.gameObject.transform; }