unity3d⿏标旋转视⾓⾃由视⾓代码
//把下⾯的代码挂在摄像机中
春节贴春联//摄像机跟随的主⾓物体
public Transform target;
//摄像机距离模型的默认距离
南瓜蒂public float distance = 20.0f;
//⿏标在x轴和y轴⽅向移动的速度
float x;
float y;
//⿏标在x和y轴⽅向移动的速度
float xSpeed = 250.0f;
float ySpeed = 120.0f;
void Start()
{
if (gameObject.GetComponent<Rigidbody>() != null)
{
gameObject.GetComponent<Rigidbody>().freezeRotation = true;
}
}个人简历电子表格
void LateUpdate()
{水的反义词
if (target)
{
//我的分析:1.根据垂直⽅向的增减量修改摄像机距离参照物的距离
distance += Input.GetAxis("Vertical");
//根据⿏标移动修改摄像机的⾓度荡芳
x += Input.GetAxis("Mou X") * xSpeed * 0.02f;
y -= Input.GetAxis("Mou Y") * ySpeed * 0.02f;
Quaternion rotation = Quaternion.Euler(y, x, 0);
劳动的句子Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position;
//设置摄像机的位置与旋转
数学哲学ation = rotation;
transform.position = position;
}
}
void Update()
{木瓜最简单的吃法
}
}