- Home /
Whats wrong with this
For one thing, you should paste in code, not pictures of code
Answer by DaveA · Aug 16, 2012 at 12:33 AM
foreach is a C# thing, use for instead
GameObject enemy won't work, use enemy : GameObject instead
I don't think you get List in JS. Use ArrayList instead. Likewise new ListTransform would be new ArrayList() instead.
Answer by aldonaletto · Aug 16, 2012 at 01:00 AM
The List declaration is wrong. You must import System.Generics.List, and declare the List as follows:
import System.Collections.Generic.List; public var targets: List.< Transform>; public var selectedTarget: Transform;
function Start(){ targets = new List.< Transform>(); ... And foreach doesn't exist in JS, as @DaveA said - it should be like this:
for (var enemy: GameObject in go){
NOTE: The space after < isn't needed in the actual code - it's there just to prevent this site to eat all the text after the character <
Actually, foreach does exist in JS, it doesn't exist in Unityscript.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Weapon Customizations Script Problem 0 Answers
Attach object as child using code 1 Answer
GuiTexture Width Change 1 Answer
Space Invaders movement? 1 Answer