【发布时间】:2018-03-30 09:13:32
【问题描述】:
大家好,我正在制作炮弹模式,玩家将拥有一个看起来像狙击屏幕的 UI 面板。这台摄像机将跟随敌人,而在常规游戏中还有另一台摄像机用于正常游戏模式(这台保持原位)。但是,当我在两者之间切换时,当我以“E”退出时,加农炮相机移动的任何位置,它都会停留在那个移动的位置。有什么方法可以手动将相机的位置恢复原位?
public class CameraFollow : MonoBehaviour
{
public Transform target;
public float smoothSpeed = 0.125f;
public Vector3 offset;
public GameObject scopeOverlay;
public GameObject Camera;
void FixedUpdate ()
{
if (Input.GetKeyDown ("d"))
{
Camera.SetActive (false);
scopeOverlay.SetActive(true);
Vector3 desiredPosition = target.position + offset;
Vector3 smoothedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed);
transform.position = smoothedPosition;
transform.LookAt (target);
}
if (Input.GetKeyDown ("e"))
{
Camera.SetActive (true);
scopeOverlay.SetActive(false); //To disable it
}
}
}
【问题讨论】: