C # moving and limiting the moving distance,
Public class PlaneMove: MonoBehaviour {
// H: horizontal direction control; v: backward direction control
Float h, v;
// Speed: aircraft Speed
Public float Speed;
// Use this for initialization
Void Start (){}
// Update is called once per frame
Void Update (){
// Horizontal value
H = Input. GetAxis ("Horizontal ");
// Vertical Value
V = Input. GetAxis ("Vertical ");
// Move one meter vertically per second
Transform. position + =-v * new Vector3 (0, 0, 1f) * Speed * Time. deltaTime;
// Move one meter per second horizontally
Transform. position + =-h * new Vector3 (1f, 0, 0) * Speed * Time. deltaTime;
// Limit the X axis-3.5 ~ 3.5, Z axis-10 ~ 1
Vector3 pos = transform. position;
Float x = pos. x;
Float z = pos. z;
X = Mathf. Clamp (x,-3.5f, 3.5f );
Z = Mathf. Clamp (z,-10f, 1f );
Pos. Set (x, pos. y, z );
Transform. position = pos;
}
}