Im currently developing a farm simulation style game and have the growing of crops stages working. Now though i need to implement the ‘harvest’ stage and have it do the growing stages but in reverse. There are three stages to the plant model giving three stages of growth.
Therefore what ive literally done is the reverse in code and it works when you only have one plot of land with that specific crop. However the user player has 9 plots and can grow a choice of three plants.
When more than one of the same crop is grown, when i choose to harvest a crop for the plot i am currently at, the game doesn’t always choose that one, it will look for the first of say plantThreeStageThree(clone).
if(harvest == true)
{
if (timeTilBuilt > 0)
{
if (PlantOneBool == true)
timeTilBuilt -= 1 * Time.deltaTime;
if (PlantTwoBool == true)
timeTilBuilt -= 1 * Time.deltaTime;
if (PlantThreeBool == true)
timeTilBuilt -= 1 * Time.deltaTime;
}
if (timeTilBuilt >= timeSet / 2)
{
if (checkPlantStageOneHarvest == false)
{
if (PlantOneBool == true)
{
Destroy(GameObject.Find("PlantOneStageThree(Clone)"));
Plant = (Transform)Instantiate(PlantOneStageTwo, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageOneHarvest = true;
}
if (PlantTwoBool == true)
{
Destroy(GameObject.Find("PlantTwoStageThree(Clone)"));
Plant = (Transform)Instantiate(PlantTwoStageTwo, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageOneHarvest = true;
}
if (PlantThreeBool == true)
{
Destroy(GameObject.Find("PlantThreeStageThree(Clone)"));
Plant = (Transform)Instantiate(PlantThreeStageTwo, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageOneHarvest = true;
}
}
}
if (timeTilBuilt <= timeSet / 2)
{
if (checkPlantStageTwoHarvest == false)
{
if (PlantOneBool == true)
{
Destroy(GameObject.Find("PlantOneStageTwo(Clone)"));
Plant = (Transform)Instantiate(PlantOneStageOne, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageTwoHarvest = true;
}
if (PlantTwoBool == true)
{
Destroy(GameObject.Find("PlantTwoStageTwo(Clone)"));
Plant = (Transform)Instantiate(PlantTwoStageOne, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageTwoHarvest = true;
}
if (PlantThreeBool == true)
{
Destroy(GameObject.Find("PlantThreeStageTwo(Clone)"));
Plant = (Transform)Instantiate(PlantThreeStageOne, new Vector3(transform.position.x + 2.5f,transform.position.y,transform.position.z), transform.rotation);
checkPlantStageTwoHarvest = true;
}
}
}
if (timeTilBuilt <= 0)
{
timeTilBuilt = 0;
if (checkPlantHarvest == false)
{
if (PlantOneBool == true)
{
Destroy(GameObject.Find("PlantOneStageOne(Clone)"));
i = 0;
amount = 10;
checkPlantHarvest = true;
PlantOneBool = false;
}
if (PlantTwoBool == true)
{
Destroy(GameObject.Find("PlantTwoStageOne(Clone)"));
i = 1;
amount = 5;
checkPlantHarvest = true;
PlantTwoBool = false;
}
if (PlantThreeBool == true)
{
Destroy(GameObject.Find("PlantThreeStageOne(Clone)"));
i = 2;
amount = 2;
checkPlantHarvest = true;
PlantThreeBool = false;
}
checkPlantStageOne = false;
checkPlantStageTwo = false;
checkPlantBuilt = false;
hasPlant = false;
harvest = false;
}
}
}
Heres the code i have at the moment and have been wrecking my brain for hours but cannot for the life of me figure it out.
Where it says Destroy(GameObject.Find("PlantTwoStageOne(Clone)"));
I thought of changing that too Destroy(transform.Find("PlantTwoStageOne(Clone)"));
or transform.Destroy(GameObject.Find("PlantTwoStageOne(Clone)"));
However these don’t work either.
I have also noticed that it will take the “PlantOneStageThree(Clone)” from a near by plot, move it to the plot i am currently harvesting and delete the original, leaving the moved plant in that plot and the plot where it has been moved from, thinking it is still there.
Any ideas folks?