Allright, it came upon me the time to code(as all the ones i tested were laggy on OSX) a mouse look function, currently it is as following:
# get cursor position(pyMouse not mouse sensor)
mouse_x = round(self.mouse.position[0],2)
mouse_y = round(self.mouse.position[1],2)
# check if user want mouse movement inverted
if self.mouse_invert_enabled == True:
mouse_invert = -1
else:
mouse_invert = 1
#Verify if mouse is still moving from its last position
if mouse_x != self.mouse_old_x:
mouse_dif_x = (self.mouse_old_x-mouse_x)*mouse_invert
self.player_col_box.applyRotation([0,0,mouse_dif_x], False)
#store a "previous mouse position" before another loop
self.mouse_old_x = mouse_x
#If mouse stopped moving(mouse_old_x = mouse_x) and isn't at screen center
elif self.mouse_old_x != 0.5:
# Center mouse in game window
render.setMousePosition(self.screen_w//2, self.screen_h//2)
The problem with the above code is which when mouse_dif_x is 0(after a cursor reentering in the screen), the player collision box return to 0 rotation(I thought if it was 0 nothing would happen); what I wanted was to add the mouse_dif_x value to the object Z axis value, not for it to be the object Z axis value; so how could I code that?
Thanks for any help