Get vector perpendicular to x,z plane

I have the following diagnostic code:

public void OnDrawGizmos() {
        Gizmos.color = Color.blue;
        for (int i = 0; i < splineSegments.Count; i++) {
            Gizmos.DrawSphere(splineSegments*, 0.25f);*

if (i < splineSegments.Count - 1) {
Gizmos.DrawLine(splineSegments*, splineSegments[i + 1]);*

// test vertices calculation
Gizmos.color = Color.red;

Vector3 left = Vector3.Cross(splineSegments - Vector3.up, splineSegments[i+1] - Vector3.up).normalized + splineSegments*;*
Vector3 right = Vector3.Cross(splineSegments[i+1] - Vector3.up, splineSegments - Vector3.up).normalized + splineSegments*;*
Gizmos.DrawSphere(left, 0.175f);
Gizmos.DrawSphere(right, 0.175f);
Gizmos.color = Color.blue;
}
}
}
The goal is to look at every vertex along a path, and create two new vectors that are on the “left” and “right” sides of the vector, perpendicular to the path. The code above SORT OF works, but it is doing the following:
[49603-crossproduct.png|49603]
I need the red spheres to be on the sides, perpendicular to the terrain. What am I doing wrong in the above code that is causing it to be in a plane perpendicular to the terrain instead of being parallel to it?
Right now it is a straight line, but it may be a curved line in the future; in case that affects the proper way to do it.

Hi,
i think that the vectors you use in the cross function are mixed, you should replace it with the following lines:

Vector3 left = Vector3.Cross(splineSegments[i+1] - splineSegments_, Vector3.up).normalized + splineSegments*;*_

Vector3 right = Vector3.Cross(Vector3.up, splineSegments[i+1] - splineSegments_).normalized + splineSegments*;*_