Orbiting in game engine without cursor problem

i usualy found some people uses mouselook script to orbit in bge,for example,GaiaForge,and it doesn’t look very smooth,the cursor has to stay in the middle of the screen and hidden,so i try several time to experiment and i finaly finished it,although it’s still not very perfect if you circle your cursor continuously,it’ll rotate a bit…
BlendFile:Orbit-fixed.blend (613 KB)

please tell me what you think about this script

~sorry english,and sorry if the property and logic bricks looks messy

I like the idea of it. It works well and I only see one problem is that after moving the camera around the orientation get off and it starts tilted along the Y axis to one side or the other. I attached a cube to the camera and you can see what im talking about here.


It is a common problem when moving something around an axis like this. An easy way to fix this is to keep your y axis rotation at 0 to keep the camera from tilting…I fixed it by added these three lines of code:
Your script:


#Orbit and move By Iqro J Putra
[EMAIL="#[email protected]"]#[email protected][/EMAIL]
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
###################################
yRot = own.worldOrientation.to_euler()       #
yRot[1] = 0                                               ###   added these
own.worldOrientation = yRot                      #    
##################################
mpos = bge.logic.mouse.position
...


adding those lines keeps your empties y rotation to 0 thus not allowing it to ''tilt". However you would have to cap the rotation to keep it from going over the top and flipping.

yeah,i noticed that problem,thanks for fixing it :wink: