Hey Guys,
I’ve created a Camera and a cube. Now I would really like to rotate the cam around the center of the cube. So I tried to use rotate.Around… but It doesnt work.
The Code is about:
if(Input.mousePosition.x < (Screen.width / 20)){
transform.RotateAround(target.transform.position, Vector3.up,1);
}
if(Input.mousePosition.x > (Screen.width / 20 * 19)){
transform.RotateAround(target.transform.position, Vector3.up,1);
}
if(Input.mousePosition.Y < (Screen.width / 10)){
transform.RotateAround(target.transform.position, Vector3.right,1);
}
if(Input.mousePosition.Y > (Screen.width / 10 * 9)){
transform.RotateAround(target.transform.position, -Vector3.right,1);
}
The rotation horizontaly works perfect… really nice. In the vertical I’ve got a huge problem… maybe you can try your own, to know what I mean. I know why it so, because the “Vector3.right” doesnt is the right rotation at every time. So sometimes Vector3.forward works good, sometimes Vector3.right… depending on where I’m in the orbit.
Do you have an solution for this problem ??
Thanks a lot
tobi