I'm trying to iron out some errors, and I admit I maybe a little too tired at the moment, but here's the thing. i am trying to iterate through a set of objects, move each one, and create a new one at the end. But I have been getting a lot of type errors, I've gotten most of them(I think) But this one eludes me. I get "InvalidCastException: Cannot cast from source type to destination type." on the for(…in…). Does anyone know why? I'm not ever sure which object its being called on.
#pragma strict
var Strait : Transform;
var childPos;
var newTail : Transform;
function Start () {
for (var child : GameObject in gameObject){
childPos = child.transform.position;
child.transform.position.z--;
if(child.transform.position.z < -1){
Destroy(child);
}
if(child.tag == "Tail"){
newTail = Instantiate(Strait, child.transform.position, Quaternion.identity);
newTail.tag = "Tail";
newTail.parent = transform;
child.tag = "Untagged";
}
}
}
With out the `#pragma strict`, I get "ApplicationException: Argument is not enumerable (does not implement System.Collections.IEnumerable).
Boo.Lang.Runtime.RuntimeServices.GetEnumerable (System.Object enumerable)
UnityScript.Lang.UnityRuntimeServices.GetEnumerator (System.Object obj)
Tube.Start () (at Assets/Tube.js:7)" And I really have no idea what that means.
↧