waypoints for airplane - non horizontal

I'm trying to set up waypoints for an airplane "in air" at various Y heights. All scripts I have tried rely on horizontal locations. How can I acheive an enemy finding the location of a way point in the closest x,y,z location? rather than only on one axis.

Some code that I wrote a while back. Just sctter the waypoints in 3D space and drag them in order one by one into waypoints array. And it will move in that loop that you have

var waypoints : Transform[];
var currentlyMoving2 : Transform;
var speedOfMotion : float;
var movingIndex : int;

function Start(){

	currentlyMoving2 = waypoints[0];
	movingIndex = 0;
	if(Vector3.Distance(transform.position , waypoints[0].position) < 0.5){
		currentlyMoving2 = waypoints[1];
		movingIndex = 1;

function Update () {

	if( Vector3.Distance(transform.position , currentlyMoving2.position) < 0.5){
		if(movingIndex == (waypoints.Length - 1)){
			movingIndex = 0;
			currentlyMoving2 = waypoints[movingIndex];
			movingIndex ++;
			currentlyMoving2 = waypoints[movingIndex];
	transform.position = Vector3.MoveTowards(transform.position,                                           currentlyMoving2.position, Time.deltaTime * speedOfMotion);

You might wanna add a few things such as facing the waypoint towards which the object is moving. I didn’t need it in my project so I didn’t write all that.
To make the object find the nearest waypoint, just use something like this in the start function:

var shortestDistance : float;
shortestDistance = Vector3.Distance(transform.position , waypoints[0].position;
nearestWaypoint : waypoints[0];
for(int i = 1 ; i < waypoints.Length ; i ++){
    if( Vector3.Distance(transform.position , waypoints*.position) < shortestDistance ){*

nearestWaypoint = waypoints*;*
shortestDistance = Vector3.Distance(transform.position , waypoints*.position;*
After this,simply make the object face nearestWaypoint and move towards it.You will need to have a boolean variable that becomes true when the object reaches the nearest waypoint and only when this variable is true, the update function does all that it needs to do, moving to the next waypoint and face them and all.
Hope this helps

Use a vertical beam that has the code saying that when it is hit by the plane it will make the plane go back to it when it crashes