- Home /
Question by
dreinzy · Apr 24, 2015 at 05:58 PM ·
camerarotationpositionroll a ball
Workaround for rotating camera OK?
I was having a problem where the position of the camera including offset was fine, but the camera was rotating along with the ball. I created a new statement fixing the rotation at 45, 0, 0. This seems to work fine, but I'm not really sure where I went wrong / what I have fixed.
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
public Vector3 offset;
void Start ()
{
offset = transform.position - player.transform.position;
}
void Update()
{
transform.rotation = Quaternion.Euler (45, 0, 0);
}
void LateUpdate ()
{
transform.position = player.transform.position + offset;
}
}
Comment
Best Answer
Answer by hbalint1 · Apr 24, 2015 at 06:32 PM
The code looks fine, but I think you put the camera as child of the Sphere. So if the Sphere rotates, the camera does too.
Your answer
Follow this Question
Related Questions
Create camera transition from one point to top of object 1 Answer
Make object appear within camera view 0 Answers
2D Aiming in a 3D game 0 Answers
camera acting weird... 1 Answer
Rotate 3rd person Character according to mouse position 0 Answers