【发布时间】:2020-05-31 01:48:07
【问题描述】:
我正在尝试围绕一个对象旋转相机,但当角度在 y 轴上达到 90 度时停止。
我找到了诸如“RotateTowards”之类的选项:https://docs.unity3d.com/ScriptReference/Quaternion.RotateTowards.html,以及诸如“RotateAround”之类的选项:https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html,但我正在尝试找到一种将两者结合起来的方法。
我尝试过但没有成功的代码:
void Update()
{
if (cameraChange && transform.rotation.y != 90)
{
// transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0, 90f, 0), Time.deltaTime * speed);
transform.rotation.RotateAround(player.transform.position, new Vector3(0, 1, 0), Time.deltaTime * speed);
}
}
void GameOver()
{
cameraChange = true;
transform.LookAt(player.transform);
}
【问题讨论】: