Remember to use codetags when posting here or heads start rolling
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraControl : MonoBehaviour {
public GameObject Player;
public float rotateSpeed = 5;
private Vector3 offset;
void Start ()
{
offset = Player.transform.position - transform.position;
}
void LateUpdate ()
{
float horizontal = Input.GetAxis("Mouse X") * (rotateSpeed * Time.smoothDeltaTime);
Player.transform.Rotate(0, horizontal, 0);
float angle = Player.transform.eulerAngles.y;
Quaternion rotation = Quaternion.Euler(0, angle, 0);
transform.position = Player.transform.position - (transform.rotation * offset);
transform.LookAt(Player.transform);
}
}