so I’m trying to figure out a chunk of code that is supposed to grab a group of objects by tag, and then create a an array of material colors to re-assign to their respective materials as a pulsing animation. the code was designed this way so any object tagged “pulse” would be capable of pulsing without any other changes made to it.
I get a clean count of 95 when I run the code, so I know it’s finding the objects and adding them to the first array. it’s when it tries to add the material colors to the second array when it breaks. I cannot find any examples of this error code online for js.
IndexOutOfRangeException: index
System.Array.System.Collections.IList.get_Item (Int32 index) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Array.cs:303)
Boo.Lang.Runtime.RuntimeServices.GetArraySlice (System.Object target, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices.GetSlice (System.Object target, System.String name, System.Object[] args)
Boo.Lang.Runtime.DynamicDispatching.SliceDispatcherFactory+<CreateGetter>c__AnonStorey12.<>m__5 (System.Object o, System.Object[] arguments)
Boo.Lang.Runtime.RuntimeServices.GetSlice (System.Object target, System.String name, System.Object[] args)
Pulse.Awake () (at Assets/Scripts/Pulse.js:57)
the code seemingly causing the bug is below:
private var objects : Array ;
private var objColor : Array ;
private var matNum : int = 1 ; // for development: materials[matNum] ... most will use 1, simple objects will use 0
private var LightsCentral : LightsoutCentral ;
function Awake()
{
stageDurations = Array ( pulseTurnOnDuration, pulseStayOnDuration, pulseTurnOffDuration, pulseStayOffDuration ) ;
objects = GameObject.FindGameObjectsWithTag ("Pulse") ;
print(objects.length);
objColor = new Array() ;
if ( objects.length > 0 )
{
for ( var i = 0 ; i < objects.length ; i++ )
{
objColor.Push (objects*.renderer.materials[matNum].color.a) ;*
-
}*
- }*
- print(objColor);*
- LightsCentral = GameObject.Find ( “ScriptStorage” ) . GetComponent ( “LightsoutCentral” ) ;*
}
any help identifying what needs fixed would be greatly appreciated!
JK