5 public Vector2
range =
new Vector2(5f, 3f);
9 Vector2 mRot = Vector2.zero;
14 mStart = mTrans.localRotation;
19 var pos = Input.mousePosition;
21 var halfWidth = Screen.width * 0.5f;
22 var halfHeight = Screen.height * 0.5f;
23 var x = Mathf.Clamp((pos.x - halfWidth) / halfWidth, -1f, 1f);
24 var y = Mathf.Clamp((pos.y - halfHeight) / halfHeight, -1f, 1f);
25 mRot = Vector2.Lerp(mRot,
new Vector2(x, y), Time.deltaTime * 5f);
27 mTrans.localRotation = mStart * Quaternion.Euler(-mRot.y *
range.y, mRot.x *
range.x, 0f);