标签:改变 记录 art col sem camera else atime log
1 public class CameraMove : MonoBehaviour { 2 3 public float speed = 3; 4 public float mouseSpeed = 300; 5 6 private float mouseMove; 7 8 void Start () { 9 10 } 11 12 13 void Update () { 14 float hor = Input.GetAxis("Horizontal"); 15 float ver = Input.GetAxis("Vertical"); 16 //if (Input.anyKeyDown) 17 //{ 18 // Debug.Log(hor); 19 // Debug.Log(ver); 20 //} 21 //限制和改变摄像头高度 22 if (transform.position.y >= 10 && transform.position.y <= 50) 23 { 24 mouseMove = Input.GetAxis("Mouse ScrollWheel");//滚轮改变摄像头高度 25 } 26 else if(transform.position.y<10) 27 { 28 //var v = transform.position; 29 //v.y = 11; 30 //transform.position = v; 31 transform.position = new Vector3(transform.position.x, 13f, transform.position.z); 32 } 33 else if (transform.position.y > 50) 34 { 35 transform.position = new Vector3(transform.position.x, 47f, transform.position.z); 36 } 37 //改变摄像机位置 38 transform.Translate(new Vector3(hor * speed, mouseMove *mouseSpeed, ver * speed) * Time.deltaTime,Space.World);//改变摄像机位置 39 } 40 }
发现限制范围时不能正好是限制的数值,比如大于10我写的是13.
不然总会有问题,会鬼畜的抽搐
我猜测是这是每一帧执行一次的,每一帧还是有时间的求大佬指点
仅作学习记录
标签:改变 记录 art col sem camera else atime log
原文地址:http://www.cnblogs.com/lywind/p/7684342.html