|
本帖最后由 monery8 于 2013-1-9 15:50 编辑
target 将目标object移动到此使用- var target : Transform;
- var distance = 20.0;
- var mySpeed = 250.0;
- private var x = 0.0;
- private var y = 0.0;
- var xMinLimit=30;
- var xMaxLimit=120;
- var yMinLimit=30;
- var yMaxLimit=120;
- function Start () {
- var angles = transform.eulerAngles;
- x = angles.y;
- y = angles.x;
- }
- function LateUpdate () {
- if (Input.GetMouseButton(1)){
- x += Input.GetAxis("Mouse X") * mySpeed * 0.02;
- x = ClampAngle(x, xMinLimit, xMaxLimit);
- y -= Input.GetAxis("Mouse Y") * mySpeed * 0.01;
- y = ClampAngle(y, yMinLimit, yMaxLimit);
- }
- var rotation = Quaternion.Euler(y, x, 0);
- transform.rotation = rotation;
- var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
- transform.position = position;
- }
- static function ClampAngle (angle : float, min : float, max : float) {
- if (angle < -360)
- angle += 360;
- if (angle > 360)
- angle -= 360;
- return Mathf.Clamp (angle, min, max);
- }
复制代码 |
评分
-
查看全部评分
|