Forum begins after the advertisement:


[Part 18] I get an out-of-index message

  • 31 August 2023: We recently fixed a bug where our Patrons were not getting their titles displayed properly on their posts.

Home Forums Video Game Tutorial Series Creating a Farming RPG in Unity [Part 18] I get an out-of-index message

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #11753
    Potato
    Former Patron

    public void LoadIncubator()
    {
    if (incubatorStatus.Count == 0) { return; }

    foreach (IncubatorBase Egg in incubatorStatus)
    {
    Incubator incubatorToLoad = incubators[Egg.incubatorID]; // here I get an out-of-index message

    if(incubatorToLoad.timeToGrow<=0)
    {
    incubatorToLoad.EggPre.SetActive(false);
    incubatorToLoad.timeToGrow = 0;
    }
    else
    {
    incubatorToLoad.EggPre.SetActive(true);
    incubatorToLoad.timeToGrow = needToGrowDays;
    }
    }
    }

    #11754
    Potato
    Former Patron

    I can’t solve this problem

    #11755
    Potato
    Former Patron

    null
    but when i debug list count is 0
    ` Debug.Log(Egg.incubatorID);
    Debug.Log(incubators.Count);
    Incubator incubatorToLoad = incubators[Egg.incubatorID];
    null

    #11756
    Potato
    Former Patron

    I have two objects in the list
    1
    But when I debug, it tells me the count is 0
    2

    #11758
    Potato
    Former Patron

    i have tow object in list
    1

    #11759
    Potato
    Former Patron

    When I debug the list count is 0
    2

    Debug.Log(incubators.Count);
    Incubator incubatorToLoad = incubators[Egg.incubatorID];

    #11760
    Potato
    Former Patron

    I fixed the problem. I had a script mount error

    #11767
    Terence
    Keymaster

    Hi Potato, glad you managed to fix the issue!

    #11757
    Potato
    Former Patron

    null
    null

    #11823
    Terence
    Keymaster

    Hi Potato, can you click on the ArgumentOutOfRangeException item on the Console and screenshot or copy the message there?

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below:

Save Soil

The Save Soil Movement

Poor farming practices and policies across the world have led to the degradation of agricultural soils in the world. This has led to the loss of nutritional value in our food over the years, and it will affect our food production capabilities in the coming decades.

Learn more about Save Soil →