FPS "Mouse Look" Function Random Drifting

Hello! I am having a weird and VERY annoying problem in UPBGE (0.2.5) where, when I use the mouse look actuator in the logic bricks, I will be looking around with my FPS character and the camera will randomly start drifting without any reason. It will normally happen when I stop moving the mouse around, and it’s only very slight, but it’s continuous. It won;t stop until I move my mouse again… My problem is that I have a background scene for a skybox with another FPS camera setup and, when I move the camera around and it starts to drift, it de-syncs the background scene camera and makes my sky all wonky. Is anyone else having this same problem? Any potential solutions? THANK YOU!

drifing or not, good chance itll desync anyway. you need to copy world orientations.

im guessing you are using an Always sensor, it should be a mouse-move sensor

Expound, please. Always sensor in regards to the mouse look actuator? I have it connected to a Mouse Move sensor with a TRUE pulse mode set. What do you mean by copy world orientations? Like, something to copy the orientation of the player camera and then translate that to the skybox camera?

Nah doesn’t matter.

The mouselook actuator is bugged in 2.5, this is due to they kept changing the behavior of grabbing the center position. If you use a basic python script it will fail as well.


However you can use my script, it got the fix build in, to compensate the off-center and calculating in true division.

The python fix for upbge 0.2.5(With thanks to the upbge community on gifthub):

w, h = render.getWindowWidth() - 1, render.getWindowHeight() - 1
center_x = w // 2 / w # truediv operation
center_y = h // 2 / h # truediv operation

for python in upbge 3.0 it’s the good old solution(means they fixed it there and restored it back like how it is in bge 2.79)

My .blend (download the correct version)

1 Like

turn off TRUE pulse mode, you most likely don’t need that to be on.
(you get the same behavior as an always sensor if it’s on )

1 Like

Thank you sir! Much appreciated! I had no idea it was a glitch commonly associated with the engine. I swore it was something I was doing wrong.


Got another question for you. Would it be possible using a simple python script to deactivate the Mouse Movement sensor when it is not being actuated? Like to get the Sensor name, and if the movement is not positive (i.e. moving), it stops any movement to the actuator? I just wanna make sure that I try all possible options. Thank you again for your help, sir!

use a simple property

‘use_mouse’ - equal True -> and -> mouse movement brick

Okay. I will try this. Thanks!

For Python, do the following if your interested.
This script will check your ‘mouse sensor’ to see if it’s activated, if it’s not being used/active, turn it off until needed or activated again.

import bge

def function(self):
  if not self.sensors["Mouse_Sensor_Name"].positive:
    return False

To check for all sensor states.

import bge

def function(self):
  for s in self.sensors:
    if not s.positive:
      return False

you could use the all() function.

if all(sensor.positive for sensor in controller.sensors):
    print("all sensors are active")

Your code doesn’t work for me until I added a boolean checking.

if all(sensor.positive for sensor in self.sensors) == False:
  return False

Thanks for sharing btw, I didn’t realize the all() statement existed.

you can simply use NOT for false.

if all(sensor.positive for sensor in controller.sensors):
if not all(sensor.positive for sensor in controller.sensors):
1 Like

Would I simply connect this to an Always sensor or run it as a controller to the mouse sensor itself?

Definitely with a Always sensor. I think it’s okay to turn off true-pulse, but not sure. I’m working atm, will check later and/or edit my post once I’ve tested it.

Okay cool, no rush. Why I ask for something like this is because whenever I use the mouse look actuator, I can literally move my mouse too fast (or just by a hair) to the left, right, up or down, and it will continue to spin endlessly until I move the mouse again (almost as if it has torque/force applied to it). So I thought having something that could shut the actuator down when not actually in use. Thank you again for your help.

1 Like

Yeah, that’s where mouse ‘sensitivity’ and ‘normalized’ coordinates come in handy.

Three days later.

Okay so I tested with 2 sensors (Always, Mouse).
Here are the things I discovered.

  • True-Pulse for either sensors will actively check for any inputs and else deactivate the sensor inputs, but not the deactivation of the True-Pulse sensor itself (Because the logic never ends unless help by other logic).
  • Level and Tap only do 1 or 2 checks because they can’t shut themselves down their selves because obviously they’re not being run infinitely.

Tested in UPBGE 0.25a (Level and Tap are different in UPBGE then Vanilla BGE)

1 Like