Make a plant grow by time? How to?

HI, im new in here, i like to do a plant that grows when i put water in it. i like to the plant grows in for example 5minutes and then it has full growth. is there a way that i can do it? thanks.

This is a bit open ended. It really depends on how you want to accomplish all of it.

at it’s basics, you would use a simple Lerp to manage the time.

float growth = Mathf.Lerp(0, 1, (endTime - Time.time) / (endTime - startTime));

This simply gives you a number between 0 and 1 based on the current time between two points. So, if you are 2.5 minutes in on a 5 minute schedule, then your response is 0.5.

Now, here is the open ended part. How are you going to represent this? You have a number between 0 and 1. Lets say that you have plants in 4 stages, seeding, 2 stages of growing and full grown. You need for each of them to be represented during this time.

int stage = (int)Mathf.Floor(growth * 4);

This now gives you a number 0, 1, 2, 3. So if you have 4 objects you simply do this:

for(int i=0; i<4; i++) plantStage[i].SetActive(false);
plantStage[stage].setActive(true);

Alternatively, you could create a single plant that grows depending through an animation. That animation could be stopped, and be 5 minutes long, and you simply tell it to play, it animates once and stops and you are done.

You can also tell that animation to be at a certain point in the cycle. And since it is stopped, it doesn’t automatically advance.

for animation: