【发布时间】:2023-03-04 16:56:01
【问题描述】:
每当我按下 Q 或 E 时,我试图让粘在播放器上的相机将其旋转 45 度。但由于某种原因,我无法让它工作。我正在使用 C#。
using UnityEngine;
using System.Collections;
public class Camera : MonoBehaviour
{
int rotatespeed = 3;
int rotationstart = 90;
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start()
{
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate() {
transform.position = player.transform.position + offset;
}
void Update()
{
if (Input.GetKey("q"))
{
Camera.main.transform.rotation = Quaternion.Euler(x + 45 , y, z);
}
if (Input.GetKey("e"))
{
Camera.main.transform.rotation = Quaternion.Euler(x - 45, y, z);
}
}
}
【问题讨论】:
标签: c# unity3d camera rotation