Programming mouse with python

Does anybody know how something like this:


might be programmed instead?

In UPBGE there are usually python templates for games. For a mouselook script, you should find ‘Character Controller First Person Camera’, and maybe ‘Character Controller Third Person Camera’, useful.

Hope this helps, ace.

Thanks! perhaps this is a silly question but how do you get them to work after attaching them to an always sensor and python logic brick?

import bge

def main(self):

  a = self.actuators["Mouse_Actuator_Name"]

  if self.sensors["Always"].positive:
    a.sensitivity_x = 2.0
    a.sensitivity_y = 2.0
    self.activate(a)

Mouse actuator attributes: https://upbge.org/#/documentation/docs/latest/api/bpy.types.MouseActuator.html

Ah, yes, so in UPBGE one can actually access python scripts through “Game Components”. This will completely circumvent logic bricks.

The way to use the First Person Camera template is to add the python component to the “Game Components” list in “Game Object Properties” in the “Properties” window. Seen here:

When adding a python component, the naming convention is python_module.ComponentClass. In the case of the First Person Camera template, it would be:

character_controller_first_person_camera.FirstPersonCamera

Python Components cannot “run” Logic Brick actuators. They can access attribute values using KX_GameObject.actuators, but they can’t set any attributes, nor run any of the methods pertaining to it.

input_controller_min_viable_product(added_mouse_look_input)2.blend (882.5 KB)
this is for 3x, to make work in 2x is usually not too hard.

would PythonComponents run actuators in future version of UPBGE?
I think it doesn’t make sense that you let component can access actuators but cannot do anything with it.

I’m no longer part of the UPBGE team, but I would expect that if the mentioned feature doesn’t already exist in UPBGE, it isn’t likely that it will be added in the future. Of course, anyone who wants to contribute a new feature to implement it can, if they have sufficient experience.