I’ve got a Camera rotating around the player.
The code works fine but I’ve been trying to get the camera to rotate smoothly for days.
Working code without smooth rotation
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateCamera : MonoBehaviour
{
public Transform TheCamera;
public int rotAmount;
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
rotAmount += 90;
TheCamera.localRotation = Quaternion.Euler(TheCamera.localRotation.x, rotAmount, TheCamera.localRotation.z);
}
if (Input.GetKeyDown(KeyCode.E))
{
rotAmount -= 90;
TheCamera.localRotation = Quaternion.Euler(TheCamera.localRotation.x, rotAmount, TheCamera.localRotation.z);
}
}
}
I tried it but it would just rotate camera around 2 degrees on every press. Im sorry if I didn’t give enough info.
The thing is that when you press [Q] the camera will rotate 90 degrees. The camera is attached to a gameobject that is following the player. The code will rotate the gameobject.