我试图使我的相机绕着分配给它的游戏对象旋转。到目前为止,我可以使它围绕游戏对象旋转,但是它向左旋转而不是向右旋转。任何帮助表示赞赏。这是我的代码。
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class CameraRotate : MonoBehaviour
{
public float speed;
float time = 5.0f;
public bool updateOn = true;
void Start()
{
StartCoroutine(updateOff());
}
void Update()
{
if (updateOn == true)
{
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
transform.Rotate(0, speed * Time.deltaTime, 0);
}
}
}
IEnumerator updateOff()
{
yield return new WaitForSeconds(10.0f);
updateOn = false;
}
}
答案 0 :(得分:0)
using UnityEngine;
using System.Collections;
public class CameraRotate : MonoBehaviour
{
public float speed;
float time = 5.0f;
public bool updateOn = true;
void Start()
{
StartCoroutine(updateOff());
}
void Update()
{
if (updateOn == true)
{
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
transform.Rotate(0, -speed * Time.deltaTime, 0);
}
}
}
IEnumerator updateOff()
{
yield return new WaitForSeconds(10.0f);
updateOn = false;
}
}