public class MovePlayer : MonoBehaviour
{
public Transform tr;
public float rotSpeed = 150.0f;
void Start()
{
tr = GetComponent<Transform>();
}
void Update()
{
float currentY = tr.rotation.eulerAngles.y;
// 오른쪽 회전
if (Input.GetKey(KeyCode.E))
{
// 로컬 기준
// tr.Rotate(Vector3.up * Time.deltaTime * rotSpeed, Space.Self);
// 월드 기준
// tr.Rotate(Vector3.up * Time.deltaTime * rotSpeed, Space.World);
tr.rotation = Quaternion.AngleAxis(currentY + Time.deltaTime * rotSpeed, Vector3.up);
}
// 왼쪽 회전
else if (Input.GetKey(KeyCode.Q))
{
// 로컬 기준
// tr.Rotate(Vector3.down * Time.deltaTime * rotSpeed, Space.Self);
// 월드 기준
// tr.Rotate(Vector3.down * Time.deltaTime * rotSpeed, Space.World);
tr.rotation = Quaternion.AngleAxis(currentY - Time.deltaTime * rotSpeed, Vector3.up);
}
}
}