Orbit a camera around a small planet: there is space for improvement


I am working on character controller that can walk on a small planet/asteroid.

example online: http://dl.dropbox.com/u/40644496/AlienAcademy/AlienAcademy.html

move char with WASD [QE = sidestep]
SPACE = jump
press “1” for follow camera (mouse sx to move camera)
press “2” for orbit camera (use arrows to move x and y axis)

Actually I have a character controller that seems to work quite well.

Also the following camera is ok (need to fix some glitching).

Now I am focused on the orbiting camera (press “2” in the web example), and I am facing some orientation problem.

I was insipred by this post: http://answers.unity3d.com/questions/53666/mouse-orbit-scritp-request.html and I have a pivot point in the center of the asteroid, when the user is in orbit mode and move the arrows (Vertical and Horizontal axis) I do:

// store current distance
x = Input.GetAxis("Vertical") * xSpeed * Time.deltaTime;
y = Input.GetAxis("Horizontal") * ySpeed * Time.deltaTime;
// rotate pivot
cameraPivotPoint.transform.Rotate(x,0,-y, Space.World);


take a look at the online example: http://dl.dropbox.com/u/40644496/AlienAcademy/AlienAcademy.html and press 2, you move to the orbit camera. From there you can use arrows to move the camera around the planet. But the X and Y orientation get crazy as I rotate. It is possible to force the rotation so that is coherent with the Input arrows?

Sorry for the bad explanation, my vector math knowledge is below zero… Hope that testing the online example you can understand the problem.

Hi sir I am keen to know how you solved this problem? @tucano