1
我有一个基于标准资产脚本的MouseOrbit脚本,我需要自定义将相机放置在轨道中的特定位置。标准脚本MouseOrbit自定义:将相机放置在现场轨道上
继承人的基础附带Unity3d:
function Start() { var angles = transform.eulerAngles; x = angles.y; y = angles.x; // Make the rigid body not change rotation if (rigidbody) rigidbody.freezeRotation = true; } function onUpdate(){ x += Input.GetAxis("Mouse X") * xSpeed; y -= Input.GetAxis("Mouse Y") * ySpeed; var rotation = Quaternion.Euler(y, x,0); var position = rotation * Vector3(0.0, 0.0, cameraDelta); transform.rotation = rotation; transform.position = position; }
我需要做的是放置在0,0
围绕目标对象的几个景点的相机。
第一个直接在对象后面。 x:7,:y0,z:0
。
这里就是我想会的工作:
function TransformCamera(x,y,z){ //set position of camera transform.position = new Vector3(x, y, z); var angles = transform.eulerAngles; y = angles.y; x = angles.x; z = angles.z; var rotation = Quaternion.Euler(y, x, z); var position = rotation * Vector3(0.0, 0.0, cameraDelta); //adjusted_target; transform.rotation = rotation; transform.position = position; }
这个脚本是关闭...它把相机和旋转,它看起来在对象,但它不会把相机在正确的位置7,0,0
。
谢谢!
谢谢它适合我。 – Neeraj