# spawn different stages of model at different stages in count down

hi guys i currently am developing a game where in one part you need to farm. when you’ve planted the seeds the plant starts to grow and has three different models depicting it’s stage of growth until fully grown. and of course each plant has a different amount of time til it’s grown. Now each plant has three of these so i am trying to work out the maths of when each model should be shown.

Times to build: plantOne = 30 seconds; plantTwo = 20 seconds; plantThree = 30 seconds;

i currently have some code thats looks like this:

``````private void Update()
{
Transform Plant;

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 >= timeTilBuilt/2)
{
if(checkPlantStageOne == false)
{
if(PlantOneBool == true)
{
Plant = (Transform) Instantiate(PlantOneStageOne, transform.position, transform.rotation);
checkPlantStageOne = true;
}
}
}
if(timeTilBuilt  <= timeTilBuilt/2) //< 16 && >14  && timeTilBuilt > (timeTilBuilt/2)-1
{
if(checkPlantStageTwo == false)
{
if(PlantOneBool == true)
{
Destroy(gameObject.transform.Find("PlantOneStageOne(Clone)"));
Plant = (Transform) Instantiate(PlantOneStageTwo, transform.position, transform.rotation);
checkPlantStageTwo = true;
}
}
}
if(timeTilBuilt <= 0)
{
timeTilBuilt = 0;
if (checkPlantBuilt == false)
{
if(PlantOneBool == true)
{
Destroy(transform.Find("PlantOneStageOne(Clone)"));
Plant = (Transform) Instantiate(PlantOneStageThree, transform.position, transform.rotation);
checkPlantBuilt = true;
}
if(PlantTwoBool == true)
{
Plant = (Transform) Instantiate(PlantTwo, transform.position, transform.rotation);
checkPlantBuilt = true;
}
if(PlantThreeBool == true)
{
Plant = (Transform) Instantiate(PlantThree, transform.position, transform.rotation);
checkPlantBuilt = true;
}
}
}

}
``````

The problem i am getting is that plant one stage one shows at the start like it should but when it gets less than half way the second model doesn’t show until the end of the timer, which the third one should appear at. (the third model does show at the end).

any ideas?

I’ve sorted the problem. just in case anyone every comes across this i’ll let you know.

because i was always depleting ‘timeTilBuilt’ it would never technically have a halfway point. Therefore i added another float called ‘timeSet’ and compared it to that one.