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
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    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
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    I can’t solve this problem

    #11755
    Potato
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    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
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

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

    #11758
    Potato
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    i have tow object in list
    1

    #11759
    Potato
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    When I debug the list count is 0
    2

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

    #11760
    Potato
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    I fixed the problem. I had a script mount error

    #11767
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Potato, glad you managed to fix the issue!

    #11757
    Potato
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    null
    null

    #11823
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    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: