transform array in javascript

hi there, this is tom again. after finishing my last project with some helpfull hints from the folks out here, I started a new project with new problems. I build a little plaza and a seeker drone should move between some points. for that I use the "SeekSteer" script from the unity Wiki pages. it works very fine when I use a drone in normal way. the script defines the destination points in an array in form of JAVASCRIPT "var waypoints : Transform[]". when I change the seeker object to a prefab, then it looses all the preset waypoints and i cant set them. do anybody has experience with that script or can tell me how to define the waypopints within the script in an form like:

waypoint[0] = Transform p1, waypoint[1] = Transform p2, waypoint[2] = Transform p3,

... thx a lot from berlin tom

To build a list of those object's transforms at runtime, you could use something like this (if you know the number of waypoints in advance):

// in c#
Transform[] waypoints = new Transform[10];

void Start()
    for (int n=0; n < waypoints.Length; ++n)
        waypoints[n] = GameObject.Find("p"+(n+1)).transform;

// or in Javascript
var waypoints : Transform[] = new Transform[10];

function Start() {
    for (var n=0; n < waypoints.Length; ++n) {
        waypoints[n] = GameObject.Find("p"+(n+1)).transform;


  • Set the number of waypoints in the line which declares the array (10, in the example above)
  • The gameObject lookup is case sensitive, so it will find objects called "p1" to "p10", but not "P1".
  • I didn't add code which checks the existence of the objects, so if one of the gameobjects does not exist or is mis-named, you'll get a null reference error.

If you have numerous scenes or situtaions where the number of waypoints might vary, you could modify this code to dynamically discover the number of waypoint objects first, before building the array. That way you wouldn't have to have a hard-coded number in your script which determines the number of waypoints.

Plae new java script send me my Email iD