Search Unity

"IndexOutOfRangeException: Index was outside the bounds of the array." bunch of console errors

Discussion in 'Editor & General Support' started by jordanemery70, Aug 25, 2019.

  1. jordanemery70

    jordanemery70

    Joined:
    Aug 24, 2019
    Posts:
    5
    Hi everyone,

    I'm using Unity 2019.1.12f1
    I did Install Unity Recorder with Package Manager --> Advanced --> Show preview Packages... Now I get a bunch of compile errors like this :

    "IndexOutOfRangeException: Index was outside the bounds of the array."

    My Waypoints script for moving objects and Aura script for volumetric light seems to not be recognized anymore. What's weird is that I can see in Camera Preview that everything works fine but not in the game tab (no light, no movement, nothing). I uninstalled Unity Recorder but nothing better happened... orf

    Please, can you help me?
    I don't understand how to resolve this and I would like to not start everything again :(

    THANKS
     
  2. jordanemery70

    jordanemery70

    Joined:
    Aug 24, 2019
    Posts:
    5
    Anyone, please ?
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is on line 14 of your script that is showing the error? Please post your code.
     
  4. jordanemery70

    jordanemery70

    Joined:
    Aug 24, 2019
    Posts:
    5
    This one is for the error in my Waypoints script. Line 14 (with the error) is in bold:
    --

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

    public class Waypoints : MonoBehaviour {

    public GameObject[] waypoints;
    int current = 0;
    float rotSpeed;
    public float speed;
    float WPradius = 1;

    void Update() {
    if (Vector3.Distance(waypoints[current].transform.position, transform.position) < WPradius)
    {
    current++;
    if (current >= waypoints.Length)
    {
    current = 0;
    }
    }
    transform.position = Vector3.MoveTowards(transform.position, waypoints[current].transform.position, Time.deltaTime * speed);

    }

    }


    --

    THANKS
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    And what is the value of current at run time, using Debug.Log or breakpoint debugging? You may have an index value out of bounds :)
     
  6. jordanemery70

    jordanemery70

    Joined:
    Aug 24, 2019
    Posts:
    5
    I did start all over again.
    Don't worry.
    Thanks a lot ;)