farming game issues with time

I’ve been making a farming game for the past few days and I’m having trouble with the growth cycle. Right now i’ve got set up to after 3 in-game days the plant goes into the next growth cycle but the problem is that

  1. i have the daysPassed set to static. the only reason i did this is because the days are on another script that is not on the plant and i had to use it in the plantcontrol script. so basically all plants have the exact same number of days passed regardless of what day they were planted. Im trying to figure a way for each individual plant wont be effected by another one being planted.
  2. if the number of days goes past 3 the plant will go to the next stage but if it past 3 days at all the plant is fully grown.

I’m still new to programming in general and im just a lil confused on what else to try.
here are the 2 scripts
PlantConrtol:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class PlantControl : MonoBehaviour
{
    public Mesh sunflower1;
    public Mesh sunflower2;

    public Mesh potato1;
    public Mesh potato2;
    //public Mesh potato3;

    public Mesh carrot1;
    public Mesh carrot2;

    public float growTime = 0;
    bool planted = false;
    public float daysToNextCycle = 3;

    public Transform plotObj;

    public string watered = "no";
    public string tilled = "no";

    UnityEvent m_planted;


    // Start is called before the first frame update
    void Start()
    {
        Calendar.a = 0;
        if (m_planted == null)
        {
            m_planted = new UnityEvent();
        }
        m_planted.AddListener(StartCycle);
    }

    // Update is called once per frame
    void Update()
    {
        if (planted == true)
        {
            daysToNextCycle = Calendar.a;
            //m_planted.Invoke();
            //growTime += Time.deltaTime;
        }
        if(daysToNextCycle > 3)
        {
            if (watered == "yes")
            {
                GetComponent<MeshFilter>().mesh = sunflower2;
                planted = false;
            }
            else
            {
                daysToNextCycle = 0;
                planted = false;
                GetComponent<MeshFilter>().mesh = sunflower1;
                GetComponent<MeshRenderer>().enabled = false;
            }
        }
    }

    private void OnMouseDown()
    {
        Debug.Log("clicked on weed");
        if(GMscript.currentTool == "Sickle")
        {
            //Destroy(gameObject);
            GetComponent<MeshRenderer>().enabled = false;
            GetComponent<MeshFilter>().mesh = sunflower1;
            growTime = 0;
            planted = false;
            Debug.Log("Weed exterminated");
        }
        if ((GMscript.currentTool == "Seeds") && (GetComponent<MeshRenderer>().enabled == false) && tilled == "yes")
        {
            GetComponent<MeshFilter>().mesh = sunflower1;
            GetComponent<MeshRenderer>().enabled = true;
            planted = true;
            //Debug.Log("Weed exterminated");
        }

        if(GMscript.currentTool == "Watering Can" && tilled == "yes")
        {
            plotObj.GetComponent<MeshRenderer>().material.color = new Color(0, 0, 1);
            watered = "yes";
        }
        if (GMscript.currentTool == "Hoe" && GetComponent<MeshRenderer>().enabled == false)
        {
            plotObj.GetComponent<MeshRenderer>().material.color = new Color(1, 0, 1);
            tilled = "yes";
        }
    }
    void StartCycle()
    {
        Calendar.a = 0;
        Debug.Log(daysToNextCycle);
    }
}

Calendar:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Calendar : MonoBehaviour
{
    float year = 1;
    public static float day = 1;
    string[] season = {"Spring", "Summer", "Autumn", "Winter"};
    int i = 0;
    public static int a = 0;
    float plant;
    PlantControl pC;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if(TimeInfo.hour > 23 && TimeInfo.min > 5)
        {
            UpdateDay();
        }
        if(day > 30)
        {
            if(i < 3)
            {
                i++;
            }
            else
            {
                i = 0;
                year++;
            }
            day = 1;
        }
        
        GetComponent<TextMeshProUGUI>().text = day + " " + season *+ " " + "year: " + year;*

if (Input.GetKeyDown(KeyCode.Space))
{
UpdateDay();
}
}
void UpdateDay()
{
day++;
a++;
//pC.daysToNextCycle++;
Debug.Log(“New Day”);
}
}

hey you are doing a hard job if u are as new as u say to programming :slight_smile:

try not to use much static variables , it may seems easy to access another script this way but you end up with problems like the ones u have right now ,

instead learn how to refrence correctly and you can make an array of variables so each of your planets get special element from the array ,