public class Planemove:monobehaviour {
H: Horizontal Direction control, V: Front and rear direction control
float h,v;
Speed: Aircraft flight speeds
public float speed;
Use this for initialization
void Start () {}
Update is called once per frame
void Update () {
Values in horizontal direction
h = Input.getaxis ("horizontal");
Values in the vertical direction
v = Input.getaxis ("Vertical");
Move vertically one metre per second
Transform.position +=-v * New Vector3 (0,0,1f) * speed * time.deltatime;
Horizontal direction One metre per second
Transform.position +=-h * New Vector3 (1f,0,0) * speed * time.deltatime;
Limit coordinates 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;
}
}
C # Moving and restricting moving distances