Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Resolved Physics error in Broadphase.cs: IndexOutOfRangeException: Index 0 is out of range of '0' Length

Discussion in 'Physics for ECS' started by Pargeno, Jan 19, 2022.

  1. Pargeno

    Pargeno

    Joined:
    Mar 7, 2014
    Posts:
    2
    I'm not sure what I'm doing wrong here, but it has kept me busy literally the whole day. Can't manage to fix it.

    I'm trying to update from 2020.1.12f1 (all works perfectly fine in this version) to 2020.3.26f1. When I did this, I managed to fix everything, no compilation errors, but as soon as I try and add a dynamic physics body I get absolutly spammed by the following error:

    Code (CSharp):
    1. IndexOutOfRangeException: Index 0 is out of range of '0' Length.
    2. Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
    3. Unity.Collections.NativeArray`1[T].CheckElementWriteAccess (System.Int32 index) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
    4. Unity.Collections.NativeArray`1[T].set_Item (System.Int32 index, T value) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
    5. Unity.Physics.Broadphase+DynamicVsDynamicBuildBranchNodePairsJob.Execute () (at Library/PackageCache/com.unity.physics@0.5.1-preview.2/Unity.Physics/Collision/World/Broadphase.cs:846)
    6. Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
    I get several of these on different locations within the same file.

    Anyone experienced this error before? I tried upgrading to 2021.2.x with the same result. I've triple checked the packages and the dependencies, they are all matched based on the versions. So I'm pretty much at a loss here.

    Packages I'm using:
    upload_2022-1-19_3-7-54.png
     
    Anthiese likes this.
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,541
  3. Pargeno

    Pargeno

    Joined:
    Mar 7, 2014
    Posts:
    2
    ooh wauw, good find! Workaround worked! Thanks man, you saved me a lot of headache for today!
     
  4. mati2762

    mati2762

    Joined:
    Dec 26, 2017
    Posts:
    14
    I have the same problem, I am upgrade my project from 2020.3.25f to 2020.3.26f and get the same erros.
    @tertle. Your post resolve problem, thx
     
  5. bb8_1

    bb8_1

    Joined:
    Jan 20, 2019
    Posts:
    98
    Yep - this(your fix) worked perfectly - thx @tertle - btw i use the latest 2020.3.29 and it still is not fixed by unity(devs) lol - ( i needed to check some simple collisions using unity(dots) physics when this bug emerged)