When my player is in the air, the camera decides to shake like crazy. Please view the video here :
When im on the floor, it works fine. I have tried using other forms of update and moving around code but nothing seems to work. Also, Player is a rigidbody ( Sphere ) if that helps
using UnityEngine;
using System.Collections;
public class camera_controller : MonoBehaviour {
public Transform PlayerTransform;
private Vector3 _cameraOffset;
public float playerRotation;
[Range(0.01f, 1.0f)]
public float SmoothFactor = 0.5f;
public bool LookAtPlayer = false;
void Start(){
_cameraOffset = transform.position - PlayerTransform.position;
}
void Update (){
transform.eulerAngles = new Vector3(0, PlayerTransform.transform.eulerAngles.y,0);
}
void LateUpdate (){
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);
if(LookAtPlayer){
transform.LookAt(PlayerTransform);
}
}
}