Arrow keys move the camera and limit the height range

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.