Movements with Python without CurrentController()

Is it possible to use a more direct path towards an object? I want to create a game in Python as much as possible without using many logic bricks, controls will not be done with the keyboard but through another program. it was my intention to use a code like this to controll rotations:


scene = bge.logic.getCurrentScene()
obj = scene.objects['player']

obj.dRot = [2, 0, 0]

# or

motion = obj.actuators['Motion']
motion.dRot = [2, 0, 0]
obj.activate(motion)

However, obj is not being recognized and I have no idea how to apply rotations in Python. Can anyone help me with this?

Accessing the game object looks fine, although try using applyRotation instead of dRot, e.g:

obj = objects.['player']

obj.applyRotation([2,0,0])

Why? What is the reason?
It is like driving a car but not using the steering wheel, gear, gas, brake, switches etc. but pulling all the little wires, ropes,
cranks that are not even directly plugged into the engine.

The BGE is not running in Python, but Python is running in the BGE.

Anyway, you have the chance right now with moguri’s component system.

Regarding your code:
You can activate actuators ONLY from controllers connected to the actuator. Forget obj.actuators it can produce errors. Better use controller.actuators.

obj.activate(…) does not exist. It is controller.activate(…)


controller = bge.logic.getCurrentController()
 
obj = controller.owner
 
# rotates with this step size at each frame 
# as long as the actuator stays active
motion = controller.actuators['Motion']
motion.dRot = [2, 0, 0] 
controller.activate(motion)

Monster