- Home /
LookAround Up&Down!
Hello! I was making a script and I want the camera to rotate around a moving object. So I writen this: var heli: Transform;
function FixedUpdate(){
if(Input.GetAxis("Mouse X")<0){
transform.RotateAround(heli.position, Vector3.up, 90 * Time.deltaTime);
}
if(Input.GetAxis("Mouse X")>0){
transform.RotateAround(heli.position, Vector3.up, -90 * Time.deltaTime);
}
if(Input.GetAxis("Mouse Y")>0){
transform.RotateAround(heli.position, Vector3.left, -90 * Time.deltaTime);
}
if(Input.GetAxis("Mouse Y")<0){
transform.RotateAround(heli.position, Vector3.left, 90 * Time.deltaTime);
}
}
It works fine with the x axis, but with the y axis doesn't. I think because I have the wrong axis, but witch is the "correct" one? Please Help me! :)
P.S.: I found a nice title, didn't I?
Answer by Graham-Dunnett · Nov 17, 2014 at 03:13 PM
Line 9 is missing an axis after the Vector3.
. Line 12 is using Vector3.zero
which isn't an axis.
On both lines, perhaps try Vector3.right
.
Yeah, my bad I had it left for both, but I was trying other vectors and forgot to change it back. But right is the same with left so I have the same result!
Your answer
Follow this Question
Related Questions
Make camera 1 transform equal to camera 2 transform 1 Answer
NullReferenceException Error 1 Answer
Move an object toward an angle in 2d space 0 Answers
Return camera to original rotation values Logic 1 Answer
Pan Orthographic Camera 0 Answers