I'm relatively new to Unity so my experience in writing code is limited.
I made a camera script that upon button press, rotates the camera on the y-axis, relative to the world space. It works, but its instantaneous. Without affecting its rotation speed or the other axes, I want to show a smooth rotation to its target axis. Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraRotation : MonoBehaviour
{
public float camRotationSpeed = 90f;
float camRotation;
private void LateUpdate()
{
RotateCamera();
}
void RotateCamera()
{
camRotation = Input.GetAxis("Camera Rotate") * camRotationSpeed;
if (Input.GetButtonDown("Camera Rotate"))
{
gameObject.transform.Rotate(0, camRotation, 0, Space.World);
}
}
}