1 Public classCameramove:monobehaviour {2 3 Public floatSpeed =3;4 Public floatMousespeed = -;5 6 Private floatMouseMove;7 8 voidStart () {9 Ten } One A - voidUpdate () { - floatHor = Input.getaxis ("Horizontal"); the floatver = Input.getaxis ("Vertical"); - //if (input.anykeydown) - //{ - //Debug.Log (hor); + //Debug.Log (ver); - //} + //limit and change camera height A if(TRANSFORM.POSITION.Y >=Ten&& TRANSFORM.POSITION.Y <= -) at { -MouseMove = Input.getaxis ("Mouse Scrollwheel");//Wheel Change camera height - } - Else if(transform.position.y<Ten) - { - //var v = transform.position; in //v.y = one; - //transform.position = v; toTransform.position =NewVector3 (transform.position.x, 13f, transform.position.z); + } - Else if(Transform.position.y > -) the { *Transform.position =NewVector3 (transform.position.x, 47f, transform.position.z); $ }Panax Notoginseng //changing the camera position -Transform. Translate (NewVector3 (Hor * speed, MouseMove *mousespeed, ver * speed) * Time.deltatime,space.world);//changing the camera position the } +}
You can't just limit the value when you find the limit, for example, greater than 10 I write 13.
There's always going to be a problem, a ghost animal twitch.
I guess this is the one time each frame is executed, and every frame is still available. Ask the big guy.
Only as a learning record
Arrow keys move the camera and limit the height range