public var curwp : Transform;
public var open : Transform[];
var bestrate: float = 10000;
var val : Transform;
function Start () {
var open = GetComponentsInChildren.<Transform>();
}
function LateUpdate () {
bestrate = 10000;
//print ("q");
for (var val : Transform in open){ <------ hear
print ("a");
var ratesorce = val.GetComponent ("score");
if (ratesorce.ttlscr < bestrate){
bestrate = ratesorce.ttlscr;
print (bestrate);
}
}
}
ime doing a script for path finding and it works without error message however it dose not print or do anything past the marked place
By using `var open` in `Start` you're redeclaring `open` as a local variable, rather than using the `open` declared in your behavior.
First of all, don't post the same question 3 times!
Second, Sneftel told you what you've done wrong, but it seems you don't have a clue what he's talking about. That's a basic logical error. You should learn some basics about programming and the scope of variables.
open is declared as public variable in your script, but in Start you declare a new local variable also called open. You want to assign the result of GetComponentsInChildren to your public variable so remove the var keyword inside Start.
It seems the same goes for your val variable. In this case you just need the local variable that is declared inside your for-loop.
public var curwp : Transform;
public var open : Transform[];
var bestrate: float = 10000;
function Start () {
open = GetComponentsInChildren.<Transform>();
}
function LateUpdate () {
bestrate = 10000;
//print ("q");
for (var val : Transform in open){
print ("a");
var ratesorce = val.GetComponent ("score");
if (ratesorce.ttlscr < bestrate){
bestrate = ratesorce.ttlscr;
print (bestrate);
}
}
}