Create a Path!

hi!

This is my script but it’s not work…

the error is: Assets/-SCRIPTS/PathScript.js(17,45): BCE0019: ‘position’ is not a member of ‘Object’.

why?!?!?!

var path : Array;
var rayColor : Color = Color.black;

function OnDrawGizmos()
{
	Gizmos.color = rayColor;
	var path_objs : Array = transform.GetComponentsInChildren(Transform);
	path = new Array();
	
	for(var path_obj : Transform in path_objs)
	{
		if(path_obj != transform)
			path[path.length] = path_obj;
	}
	for(var i : int = 0; i < path.length; i++)
	{
		var pos : Vector3 = path[i].position;
		if(i>0)
		{
			var prev : Vector3 = path[i-1].position;
			Gizmos.DrawLine(prev,pos); 
		}
	}
}

Should this not be?
if(path_obj == transform)

If I was you I would just use a generic collection.

Yes absolutely stop using the bad, untyped js Array, GetComponentsInChildren already returns a builtin T[ ] array, so use that
http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F

Your first for loop only ever sets the last element in path, but you never add anything to path (does setting an element to an unsized Array automatically Push it? So bad)

Anyway, if path is typed, you wont get the error about position not belonging to it

Thankkkkkkksksksskskskkssksksksk!!!