I am making mouse wheel interaction in BGE. I found some mouse wheel events are skipped when I scroll wheel very fast. I think this is because Mouse Sensor Logic Brick is activated only once a frame. I need a value how many times mouse wheel is scrolled in a frame, it is maybe called "mouse wheel delta" in some of other environments.

Is it possible to get "mouse wheel delta"? If yes, how can I get it in python?



Turn on [True Level Triggering] at the mouse wheel sensor.

How it works

The mouse wheel measures the "clicks" of the wheel (as estimation of the distance).

Frame f+0:

The sensor evaluates positive when the wheel clicked (at least once). The sensor will trigger the connected controllers, which activate the connected actuators. I guess your controller is counting. The property actuator will deactivate itself after adding +1

Frame f+1

Case: not clicked

When the wheel is not clicked within the next frame, the sensor will evaluate not positive, triggering the connected controller which deactivates the connected actuator. In case of a property actuator, it is deactivated already. So nothing happens (which is correct).

Case: clicked

When the wheel is clicked again, the sensor evaluates positive. As the sensor is already positive the sensor will not trigger the connected controllers which means the actuators remain as they are (deactivated). This is what happens right now.

When you enable [True Level Triggering] the sensor will trigger the connected controllers. Due to the positive evaluation result of the sensor the controller will activate the connected actuators. The property actuator will add +1 and deactivate itself. This is what you want.

Remarks: I can't tell what happens if you are able to spin the mouse wheel that fast that you get two or more clicks with a frame. This should be a rare case.

I hope this helps

  • $\begingroup$ True Level Triggering worked fine. $\endgroup$ – acidhead Oct 11 '17 at 21:54
  • $\begingroup$ Thank you. I am using these kind of mouse. M500 So I can spin very fast. And it works correctly even on 5fps. They must live in a different thread than the rendering thread. $\endgroup$ – acidhead Oct 11 '17 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.