Search Unity

[Cinemachine] Array index is out of range?

Discussion in 'Cinemachine' started by Glowing_Slab, Aug 31, 2018.

  1. Glowing_Slab

    Glowing_Slab

    Joined:
    Jun 19, 2015
    Posts:
    27
    I occasionally pick up lots of errors from the Cinemachine FreeLook cameras I'm using. Am I missing something obvious?

    Error is:

    IndexOutOfRangeException: Array index is out of range.
    Cinemachine.CinemachineFreeLook.UpdateCachedSpline () (at /Users/me/Library/Unity/cache/packages/packages.unity.com/com.unity.cinemachine@2.2.7/Runtime/Behaviours/CinemachineFreeLook.cs:634)
    Cinemachine.CinemachineFreeLook.GetLocalPositionForCameraFromInput (Single t)

    ... which makes me wonder if it's something to do with the vcam initial position?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,608
    I've never seen those. If you can manage to repro consistently, please file a bug report with full repro steps and we'll get right on it.
     
  3. SideEffectsDave

    SideEffectsDave

    Joined:
    Jul 16, 2018
    Posts:
    1
    We get the same error (seemingly at random and only within the editor). We can reproduce it (more or less consistently) when we build the project or publish/update the scene containing the Cinemachine Brain using Unity Collaborate. It first appeared when someone copied a Freelook Camera in the scene containing the Cinemachine Brain and published the changes using Unity Collaborate. After that the Freelook Cameras started exposing their Rigs in the hierarchy when activated/deactivated.

    To fix it we open a scene not containing a cinemachine brain then reimport the scene containing the Cinemachine Brain and the error is gone (at least for a while :D).
     
    Last edited: Sep 4, 2018
  4. Glowing_Slab

    Glowing_Slab

    Joined:
    Jun 19, 2015
    Posts:
    27
    Interesting! I also use Collaborate, and would certainly have copied a Freelook camera too. I use three Freelook cameras and two brains in the scene. I found the issue difficult to reproduce, but it only occurs in the editor. I have also seen some of the Freelook cameras exposing at least part of their rigs on occasion.
     
  5. JonneSir

    JonneSir

    Joined:
    Jun 27, 2018
    Posts:
    2
    I had this same problem. I restarted the scene and it seems to have dissapeared.
     
  6. Glowing_Slab

    Glowing_Slab

    Joined:
    Jun 19, 2015
    Posts:
    27
    Sometimes it takes a while to reappear, restarting has not solved the issue for me.
     
  7. dval

    dval

    Joined:
    Jul 25, 2012
    Posts:
    17
    Edit:
    I just removed ExecuteInEditMode from the directives in CinemachineBrain.cs.
    Works fine in playmode. No more errors in edit mode.

    Any reason to keep ExecuteInEditMode?


    Yeah, this is still a thing. I get:
    IndexOutOfRangeException: Index was outside the bounds of the array.
    Cinemachine.CinemachineFreeLook.UpdateCachedSpline () (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineFreeLook.cs:617)
    Cinemachine.CinemachineFreeLook.GetLocalPositionForCameraFromInput (System.Single t) (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineFreeLook.cs:597)
    Cinemachine.CinemachineFreeLook.PushSettingsToRigs () (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineFreeLook.cs:534)
    Cinemachine.CinemachineFreeLook.InternalUpdateCameraState (UnityEngine.Vector3 worldUp, System.Single deltaTime) (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineFreeLook.cs:283)
    Cinemachine.CinemachineCore.UpdateVirtualCamera (Cinemachine.CinemachineVirtualCameraBase vcam, UnityEngine.Vector3 worldUp, System.Single deltaTime) (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Core/CinemachineCore.cs:288)
    Cinemachine.CinemachineCore.UpdateAllActiveVirtualCameras (System.Int32 layerMask, UnityEngine.Vector3 worldUp, System.Single deltaTime) (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Core/CinemachineCore.cs:209)
    Cinemachine.CinemachineBrain.UpdateVirtualCameras (Cinemachine.CinemachineCore+UpdateFilter updateFilter, System.Single deltaTime) (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineBrain.cs:293)
    Cinemachine.CinemachineBrain.LateUpdate () (at Library/PackageCache/com.unity.cinemachine@2.2.0/Runtime/Behaviours/CinemachineBrain.cs:242)


    Every second my mouse is over the Scene window. It happens more often if I move the mouse.
    So, just opening the project, I am greeted with about 40 error messages. Nothing seems to be broken gameplay wise, but it makes it hard to see actual issues.
     
    Last edited: Feb 10, 2019
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,608
    I would strongly recommend upgrading to the latest version of CM, which currently is 2.2.8.
     
  9. krishnarocks1900

    krishnarocks1900

    Joined:
    Jul 6, 2019
    Posts:
    1
    restarting scene helped me and yea update to latest version first