I am trying to create a rotation system around my character so that when i hold down right mouse button and move the mouse, the camera rotates round the character and when you let go of it, the view stays where it is. Once you let go, you can use the custom mouse pointer to click on items in the scene.

I have the problem that when you rotate the camera, the pointer snaps to the center of the screen (when i want it to stay in place) and jolts the camera. I am aiming for a way to have a similar system to the game Astroneer for reference. Any idea of how i could achieve this?

  • 4
    $\begingroup$ The mouse-look sensor works by centering the mouse each frame, and measuring the amount that it rotates by. The easiest way to 'fix' this is to use a custom mouselook script that saves the mouse position when clicked, and restores the mouse position after the button is released. $\endgroup$
    – sdfgeoff
    Commented Jan 11, 2018 at 14:05

2 Answers 2


I've programmed several mouselook scripts. All of them are referencing to the center of the screen which is normal. Only thing you need to do is to set the reference to where your click RMB.

EDIT: Not nice but here is an old one I modified:

from bge import logic, render

def mouselook():
 #get needed properties
 res_x = render.getWindowWidth()
 res_y = render.getWindowHeight()
 mid_x = own['mid_x']
 mid_y = own['mid_y']
 sens = 0.001

 # get rotation
 x = (mid_x-(res_x*logic.mouse.position[0]))*sens
 y = (mid_y-(res_y*logic.mouse.position[1]))/2*sens

 # look left/right

 # look up/down

 # reset mouse to center
 render.setMousePosition(mid_x , mid_y)

cont = logic.getCurrentController()
own = cont.owner
look = cont.sensors['look']
rmb = cont.sensors['rmb']

if rmb.status == 1:
 own['mid_x'] = logic.mouse.position[0] * render.getWindowWidth()
 own['mid_y'] = logic.mouse.position[1] * render.getWindowHeight()

if look.positive and rmb.positive:

Here the logics attached to the camera: logic attached to camera

  • 1
    $\begingroup$ Not a fan of the one space indenting. 4 is recommended. $\endgroup$
    – batFINGER
    Commented Feb 17, 2018 at 11:58
  • $\begingroup$ Yeah, me too. Usually I use Tabs but as I mentioned this is a really old one. My very first beginnings of python and blender. $\endgroup$
    – Richy
    Commented Feb 17, 2018 at 12:26
  • $\begingroup$ .. could be modified a little more IMHO. (eg 4 space tabs) $\endgroup$
    – batFINGER
    Commented Feb 17, 2018 at 12:31

You need two modes/states

  • view change mode where you turn the camera with mouse movement. Typically the mouse cursor is not shown in this mode
  • click mode where you can see and move the mouse cursor. The camera is not turned by the mouse.

You need to define when to switch from one mode/state to the other


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .