void Update (){target = GameObject.Find("new_offer");// 滾輪設置 相機與人物的距離.if(Input.GetAxis("Mouse ScrollWheel") != 0){theDistance = theDistance + Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * ScrollKeySpeed;}// 鼠標中間滾動得到的值是不確定的,不會正好就是0,或 -10,當大于0時就設距離為0,小于MaxDistance就設置為MaxDistanceif(theDistance>0){ theDistance = 0;}if(theDistance < MaxDistance){ theDistance = MaxDistance;}transform.position = target.transform.position;SetDistance();}void Start (){if (rigidbody){rigidbody.freezeRotation = true;transform.position = target.transform.position;}}//設置相機與人物之間的距離void SetDistance(){transform.Translate(Vector3.forward * theDistance);}請問,運行時發現攝像頭只是上下移動,并不實現拉近后退的效果,這是為什么?
unity3d鼠標滾輪實現攝像頭拉近后退
幕布斯7119047
2019-02-12 13:08:00