Making the player the camera's axis of rotation.
I have some code that i thought of to make the camera turn whenever the player turns, yet the player goes out of focus. I have no idea how to fix this (although I believe I may know the source of the problem). Can someone help?
Code:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position + offset;
transform.rotation = player.transform.rotation;
transform.Rotate (new Vector3 (45, 00));
}
}
Pictures to show the struggle:
2016-03-18-20-33-55-01.jpg
(372.4 kB)
Comment
Your answer
Follow this Question
Related Questions
Camera Rotation Around Player 1 Answer
Problems with rotating the player on the Y axis C# 0 Answers
Recognize when ever camera looks up and turns back down 0 Answers
How do i limit the rotation of a game object in relation to a free following camera ? 0 Answers
No overload for method 'RotateAround' takes one argument 1 Answer