[英]How to rotate camera around the player after level up in Unity
I am making a simple game in unity and I want when level up, simple when player trigger to collider, Camera start rotate around the player. 我正在团结一致地制作一个简单的游戏,想要升级时,当玩家触发对撞机时很简单,相机开始围绕玩家旋转。
How can I do this? 我怎样才能做到这一点?
I am using C# script, and I assign a camera and player to it. 我正在使用C#脚本,并为其分配了摄像机和播放器。 My code is not working yet. 我的代码尚无法使用。
This is my Code here: 这是我的代码在这里:
public Camera MainCam;
public GameObject target;
if (!failLevel && !level_up)
{
MainCam.transform.RotateAround(target.transform.position, new Vector3(0.0f, 1.0f, 0.0f), 10 * Time.deltaTime);
failLevel = true;
gameEnd = true;
}
You need to rotate it in the Update function. 您需要在更新功能中旋转它。 This code will run only once. 此代码将仅运行一次。 Try something like this: 尝试这样的事情:
if (!failLevel && !level_up) {
rotateAround = true;
failLevel = true;
gameEnd = true;
}
void Update()
{
if(rotateAround) {
MainCam.transform.RotateAround(target.transform.position, new Vector3(0.0f, 1.0f, 0.0f), 10 * Time.deltaTime);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.