Forum begins after the advertisement:


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

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
    Participant

    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
    Participant

    I can’t solve this problem

    #11755
    Potato
    Participant

    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
    Participant

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

    #11758
    Potato
    Participant

    i have tow object in list
    1

    #11759
    Potato
    Participant

    When I debug the list count is 0
    2

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

    #11760
    Potato
    Participant

    I fixed the problem. I had a script mount error

    #11767
    Terence
    Keymaster

    Hi Potato, glad you managed to fix the issue!

    #11757
    Potato
    Participant

    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: