Python Mouselook issues

Hi, I managed to code the following function for mouse looking(only in the x axis for now) in my game:

	# Define mouse look mode
	def mouseLookMode(self):										

		# Check if user want mouse movement inverted
		if self.mouse_invert_enabled == True:
			mouse_invert = -1
			mouse_invert = 1

		# Rotate accordingly to how much the mouse moved from the screen center
		self.player_col_box.applyRotation([0,0,((0.5-self.mouse.position[0])*self.mouse_sensitivity)*mouse_invert], False)

		# Recenter mouse
		if self.mouse.position[0] != 0.5:
			render.setMousePosition(self.screen_w//2, self.screen_h//2)

The problem is which the mouse look acts (in the lack of better words) ‘laggy’, even with 60 frames per second, I also verified which all the mouse look scripts I could get my hand on here on this forum behaves this way too, even with other users saying it works fine for them.

I’m on OSX Lion, and noted which removing the bge render.setMousePosition() function from my code makes it behave normally, but the mouse look stops as soon as the mouse reaches the screen borders(as expected); and believe me, I tried a lot of ways of reducing the number of times setMousePosition(in hope of having any improvement) is called, but I could only reduce this issue, not eliminate it.

Thanks for any help regarding this

OBS: The mouse is an iMac standard magic mouse, and works fine outside BGE or in it without the setMousePosition() function

I think there was an issue with mouses with Mac. Anyway, have you tried the one in the BGHelper module? (It uses the same mouse setting function, but still). You could check to see if the mouse’s position is off-screen, then set it back. That would minimize it, but you’ve probably already tried that, huh?

But when the Mouse Position is not automatically set to 0.5 again afterwards, then the Mouse Movement Direction can not get taken into account: You would move the Mouse to the Left, Camera turns left, then turn it to the Right, Camera would still turn left because the Mouse is still in the left Part of the Screen. But if not using applyRotation, it might work better: If the Rotation could be assigned instead of being added, then centering the Mouse would not be needed. Unfortunately, the Commands to set the Orientation are way too confusing for me. ;_;

I must correct myself.


That was pretty easy, actually.

BGHelper module? Can you give more details? Also you are right, I already tried to call setMousePosition only on at screen edges, it does minimized the problem, but not eliminated it. The logic I used was which when the mouse got at a screen edge it would be repositioned to the opposite edge, I tried many ways as I said above, and most of them worked, but setMousePosition() messed everything in different degrees. I already lost quite an amount of time in this issue for now.

I checked your mouse look test in the blend, it gave me the same results. But I think I will take a look at the other functions there, I was in need of a full python track to for my game camera and Nodepath movement for game characters and cutscenes.

So, is there a bug report already for this issue? I want to completely eliminate this issue, not minimize it

EDIT1: Already submited a bug report about this