BGE Camera Help

ok im trying to figure out how to setup the camera in bge to act like the camera in modeling mode. where you click the middle mouse button and can pan around the object its locked to.
i would like to use logic bricks to achieve this cause i dont know how to use python. but if someone can setup a python that would be awsome:D

any and all help is appreciated. i wont be able to respond for a couple of hours, got to work. but when i can ill pick up from there. thanks:cool:

Hmm. Well, if you parent the camera to a cube, positioned where you want it, then rotating the mouse could rotate the cube, making the camera orbit around the object perfectly.

EDIT: I’ll have to make an example blend.

Okay. Here’s the blend - there are two scripts inside. One is a more ‘willy-nilly’ orbiting script, while the other (OrbitFixed) is more likely to be what you want. I enabled the mouse cursor to be visible with the ‘Mouse Cursor’ button in the Render (Camera) tab so that you could see what the script’s doing. If you want to change the sensitivity, change the speed value in the script to be something else.

Orbit.blend (480 KB)

EDIT: If you want to change which script it running, simply select the one you want in the script menu inside of the Python controller (the CameraHelper object (the Cube) is running the script).

sorry i couldnt reply earlier, but this is exactly what i was looking for the fixed orbit is the perfect fit for me!! thanks again solarlune for solving both of my problems.

Will this script work in 2.49?

No, it won’t. If someone wants to port it, though, it’s fairly simple.

I also notice that the mouse cursor stays to the fixed position. What changes would one have to make to this script to allow to have this type of movement while still being able to control the mouse like in the blender program.

Very nice Solarlune!

@3D - Thanks. I like the result, as well.
@phreak - Well, it’s sets the mouse’s position to be centered so that it can easily move around - if you don’t set the mouse position to the center of the screen, then it would be possible to, say, not be able to rotate an object around because the cursor’s too far to the left (and so can’t move any more). An alternative would be to set the position of the mouse only when the button is pressed, and set it back to the original position when you let go - Here’s an example blend.

In the blend file, if you press the middle mouse button, orbiting will begin and it will save the position of the mouse cursor before orbiting - when you release the orbit button, the mouse cursor will return to its original position.

I also added another script (OrbitSpeed) which will orbit the object by how far from the middle of the screen the mouse is.

Orbit.blend (484 KB)

Script works great! Another question however. Instead of bringing the mouse cursor back to the center of the screen each time the middle mouse button is clicked, and then rotating around the cursor, what would it take to create a small object (possibly transparent) at the position in which you want the rotation to take place and then whenever the middle mouse button is pressed and the mouse is moved it would then rotate around that object allowing the cursor to stay in the position the user had it in?

That’s an idea - it could do that, but the problem is that it would still basically rely on the mouse’s being in the center of the screen to place the referencing object. It may or may not work, depending on your setup. An easy fix would be to hide the mouse cursor and make another mouse cursor that is in the mouse’s position - when you middle-mouse button click to orbit, then the real cursor wouldn’t move to the center of the screen.