- Home /
This question was
closed Dec 12, 2014 at 09:03 PM by
Slulego for the following reason:
Problem is not reproducible or outdated
Camera Zoom from rotation.
I need to get the camera to zoom in when looking up or down, but come back to the default distance when looking straight.
The following code only works for looking down:
private var PrevX;
private var CurX;
function Start() {
PrevX = transform.parent.transform.eulerAngles.x;
}
function Update () {
CurX = transform.parent.transform.eulerAngles.x;
//Looking Up
if (CurX > 180) {
transform.Translate( 0, 0, (PrevX - CurX) / 20);
//Looking Down
} else if (CurX < 180) {
transform.Translate( 0, 0, (CurX - PrevX) / 20);
}
PrevX = transform.parent.transform.eulerAngles.x;
}
Have any ideas, or suggestions?
Comment
Follow this Question
Related Questions
Bizzare problem with limiting camera veritcal rotation 2 Answers
Basic Camera rotation and Zoom 0 Answers
Limit rotation angle on Z axis while slerp 1 Answer
Need help implementing a zoom function 0 Answers