左右键水平方向转动,上下键垂直方向转动
旋转摄像机的代码是
var dt = Time.deltaTime;
x -= Input.GetAxis(“Horizontal”) * horizontalSpeed * dt;
y += Input.GetAxis(“Vertical”) * verticalSpeed * dt;
y = ClampAngle(y, minVertical, maxVertical);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
转载请注明:陈童的博客 » web3d — 卧室场景