Answer the question
In order to leave comments, you need to log in
Unit error: IndexOutOfRangeException: Index was outside the bounds of the array?
Hello, I was creating an inventory for a game and ran into this error: "IndexOutOfRangeException: Index was outside the bounds of the array."
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sobiraenpredmetu : inventoryipob
{
private inventoryipob inventoey;
public GameObject slotButton;
private void Start()
{
inventoey = GameObject.FindGameObjectWithTag("Player").GetComponent<inventoryipob>();
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
for (int i = 0; i < inventoey.slots.Length; i++)
{
if(idfull[i] == false)
{
idfull[i] = true;
Instantiate(slotButton, slots[i].transform);
Destroy(gameObject);
break;
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question