Gameobject - gameobject

how would i do this

var gos : Gameobject[]; var nearestwaypoint : Gameobject;

var attempt (Gameobject in gos - nearestwaypoint);

all i get are errors saying i cant subtract a gameobject var from another gameobject var.

What are you trying to achieve? Find the distance between a game object and your nearest waypoint (which is just a rough guess)?

If that's the case, try this:

var nearestWayPoint : Transform;

function Update () {
var dist = Vector3.Distance(nearestWayPoint.position, transform.position);
print ("Distance to Waypoint: " + dist);
}

Put this script on the game object which you want the distance for (e.g. your first person controller) and drag your waypoint object onto the nearestWayPoint slot in the Inspector.