- Home /
Question by
joseph b · May 09, 2011 at 12:47 PM ·
invalidcastexceptiongetcomponentsinchildren
short script error mesige
public var curwp : Transform; public var open : Transform[];
function Start () { open = GetComponentsInChildren(Transform); <------ }
function LateUpdate () { bestrate = 10000;
for (var value : Transform in open){
print (3);
var ratesorce = value.GetComponent (score);
if (ratesorce.ttlscr < bestrate){
print (4);
bestrate = ratesorce.ttlscr;
}
}
}
InvalidCastException: Cannot cast from source type to destination type. controler.Start () (at Assets/controler.js:5)
problem is the get component in children in function start.
my mane question is am I using the right function.
this is part of a path finding script and get component in children refers to nodes contained in the object this script is in.
any solutions.
Comment
Answer by Mike 3 · May 09, 2011 at 12:52 PM
Answered this a couple hours ago - use the generic version of the function: