I found some c# code that lets you do this, but it’s very very glitchy. Doesn’t have any center, and always faces one direction even when the object the camera is attached to rotates.
using UnityEngine;
using System.Collections;
public class Camera : MonoBehaviour {
public float speedH = 3.0f;
public float speedV = 2.0f;
private float yaw = 0.0f;
private float pitch = 0.0f;
void Update () {
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
}
How would I make a camera that always faces the direction the object is facing, and also have it rotate with the mouse so it can look left and right, without the camera angle glitching, being weird and not having anything centered at all?