- Home /
This question was
closed Jan 27, 2015 at 03:46 PM by
unimechanic for the following reason:
Duplicate Question
Prevent camera from rolling while looking at object
I have some code here that's supposed to change the perspective of the camera to above the ball as it moves around the plane;
public Camera playerCamera;
public Transform attention;
public GameObject playerBall;
private float height;
void Start () {
height = playerCamera.transform.position.y;
}
void Update () {
playerCamera.transform.position = playerBall.transform.position + new Vector3(0.0f, height, 0.0f);
playerCamera.transform.LookAt (attention);
}
The camera is looking directly down from above the ball in the scene, and the attention
transform is the center of the platform. When running the code, the camera rotates around to always be facing up, but I don't want that functionality. I want its local y
coordinate to stay the same rotation no matter what, so that the arrow keys always move the ball in the same direction relative to the camera's orientation.
Comment
Answer by unimechanic · Jan 27, 2015 at 03:46 PM
That has nothing to do with my problem. Please don't just post links and expect whatever you link to be the correct answer.