- Home /
can't get this right... help please...
hi all...
i have come up with this error when im converting C# to JavaScript..
the C# is fine... only in the JavaScript have the problem..
i have 3 errors...
BCE0048 : Type 'UnityEngine.GameObject' does not support slicing.
BCE0067 : There is already a local variable with the name 'i'.
BCE0019 : 'Length' is not a member of 'UnityEngine.GameObject'.
here's the script...
DirectionX = 0;
for(var i : int = 0; i < _collider.Length; i++){
_collider[i].GetComponent(BoxCollider).isTrigger = true;
}
yield WaitForSeconds(WaitTime);
for(var i : int = 0; i < _collider.Length; i++){
_collider[i].GetComponent(BoxCollider).isTrigger = false;
}
Wait = false;
}
thanks for your help.. totally appreciate it...
^_^
Answer by aldonaletto · Mar 22, 2012 at 11:27 AM
Errors 1 and 3: You have a problem in the _collider array declaration (not included in the code above) - it probably should be:
var _collider: GameObject[];
Error 2: In JS, variables defined in loop statements or inside brackets aren't local to them (different from C#). Remove the var keyword from the second for - the variable i declared in the first for exists in the whole function.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065415im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
what's wrong with this?? 2 Answers
Distribute terrain in zones 3 Answers