Unity creating curved path

Hey I started coding in C# with Unity and I want to make a GameObject to follow a curved path defined by the function y=sqrt(x)-3  I looked online and I didn't see any tutorial or guide showing how to do this.

 

if (position_z <= 4 && position_z >= -4) {

float z = Mathf.Sqrt(position_x)-3;

transform.position = new Vector3 (position_x, 0, z);

}

 

The x and y position works but the z value is NaN.

Any idea how to fix this?

Ok I think I can narrow this down to two possible problems:

  • Maybe negate 3.0 instead since 3 may be taken as an integer and Sqrt should return a double or float.
  • position_x could be negative, which the square root of is undefined. Not sure if that would cause it to throw an exception but this could be the case.