0
\$\begingroup\$

I am using a Trigger Custom Events node in Unity Visual Scripting. It usually works but around 5% of the time... I get an error that says:

<< ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index >>

enter image description here

The Trigger is received in another GameObject, as shown here:

enter image description here

In both cases, the Arguments is set to 0. Here is the full text of the error from the Console:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.ArrayList.get_Item (System.Int32 index) (at <6073cf49ed704e958b8a66d540dea948>:0)
Unity.VisualScripting.GetListItem.Get (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Collections/Lists/GetListItem.cs:50)
Unity.VisualScripting.Unit+<>c__DisplayClass86_0`1[T].<ValueOutput>b__0 (Unity.VisualScripting.Flow recursion) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Unit.cs:353)
Unity.VisualScripting.Flow.GetValueDelegate (Unity.VisualScripting.ValueOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:650)
Unity.VisualScripting.Flow.GetValue (Unity.VisualScripting.ValueOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:591)
Unity.VisualScripting.Flow.GetValue (Unity.VisualScripting.ValueInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:535)
Unity.VisualScripting.SetVariable.Assign (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Variables/SetVariable.cs:64)
Unity.VisualScripting.Flow.InvokeDelegate (Unity.VisualScripting.ControlInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:456)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:347)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.For.Loop (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Control/For.cs:94)
Unity.VisualScripting.Flow.InvokeDelegate (Unity.VisualScripting.ControlInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:456)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:347)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Run (Unity.VisualScripting.ControlOutput port) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:240)
Unity.VisualScripting.EventUnit`1[TArgs].Run (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:182)
Unity.VisualScripting.EventUnit`1[TArgs].Trigger (Unity.VisualScripting.GraphReference reference, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:154)
Unity.VisualScripting.EventUnit`1+<>c__DisplayClass14_0[TArgs].<StartListening>b__0 (TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:67)
Unity.VisualScripting.EventBus.Trigger[TArgs] (Unity.VisualScripting.EventHook hook, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:71)
Unity.VisualScripting.EventBus.Trigger[TArgs] (System.String name, UnityEngine.GameObject target, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:80)
Unity.VisualScripting.CustomEvent.Trigger (UnityEngine.GameObject target, System.String name, System.Object[] args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/CustomEvent.cs:67)
Unity.VisualScripting.TriggerCustomEvent.Trigger (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/TriggerCustomEvent.cs:90)
Unity.VisualScripting.Flow.InvokeDelegate (Unity.VisualScripting.ControlInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:456)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:347)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Run (Unity.VisualScripting.ControlOutput port) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:240)
Unity.VisualScripting.EventUnit`1[TArgs].Run (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:182)
Unity.VisualScripting.EventUnit`1[TArgs].Trigger (Unity.VisualScripting.GraphReference reference, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:154)
Unity.VisualScripting.EventUnit`1+<>c__DisplayClass14_0[TArgs].<StartListening>b__0 (TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:67)
Unity.VisualScripting.EventBus.Trigger[TArgs] (Unity.VisualScripting.EventHook hook, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:71)
Unity.VisualScripting.EventBus.Trigger[TArgs] (System.String name, UnityEngine.GameObject target, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:80)
Unity.VisualScripting.CustomEvent.Trigger (UnityEngine.GameObject target, System.String name, System.Object[] args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/CustomEvent.cs:67)
Unity.VisualScripting.TriggerCustomEvent.Trigger (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/TriggerCustomEvent.cs:90)
Unity.VisualScripting.Flow.InvokeDelegate (Unity.VisualScripting.ControlInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:456)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:347)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Invoke (Unity.VisualScripting.ControlOutput output) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:351)
Unity.VisualScripting.Flow.Run (Unity.VisualScripting.ControlOutput port) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:240)
Unity.VisualScripting.EventUnit`1[TArgs].Run (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:182)
Unity.VisualScripting.EventUnit`1[TArgs].Trigger (Unity.VisualScripting.GraphReference reference, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:154)
Unity.VisualScripting.EventUnit`1+<>c__DisplayClass14_0[TArgs].<StartListening>b__0 (TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/EventUnit.cs:67)
Unity.VisualScripting.EventBus.Trigger[TArgs] (Unity.VisualScripting.EventHook hook, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:71)
Unity.VisualScripting.EventBus.Trigger[TArgs] (System.String name, UnityEngine.GameObject target, TArgs args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Events/EventBus.cs:80)
Unity.VisualScripting.CustomEvent.Trigger (UnityEngine.GameObject target, System.String name, System.Object[] args) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/CustomEvent.cs:67)
Unity.VisualScripting.TriggerCustomEvent.Trigger (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Events/TriggerCustomEvent.cs:90)
Unity.VisualScripting.Flow.InvokeDelegate (Unity.VisualScripting.ControlInput input) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:456)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:394)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:381)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:381)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:381)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__55.MoveNext () (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Flow.cs:398)
Unity.VisualScripting.Flow+<InvokeCoroutine>d__<message truncated> 

Two things about this error are especially confusing:

  1. The code usually works exactly as intended. It only throws an error about 5-10% of the time...
  2. The error states that the Parameter name is Index... which parameter is that, is that the Argument?

Any insight into what could cause this, or ideas on how to fix it? Thank you!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Did you try opening the files indicated in the stack trace, to see what code is executing on the line that caused the error? We can see it's looking up into an ArrayList variable. Do you have such a variable in one of your scripts/graphs that this CustomEvent is invoking? What does startSuperNeemGenerator look like? \$\endgroup\$
    – DMGregory
    Sep 20 at 12:17

0

You must log in to answer this question.

Browse other questions tagged .