Mouse Just Activated

Hi everybody,

Here’s what I got:

mouse = bge.logic.mouse
click = mouse.inputs[bge.events.LEFTMOUSE].queue

I want it to be on “just activated” when I click. I looked at the documentation and it said that queue can contain “bge.logic.KX_INPUT_JUST_ACTIVATED” and “bge.logic.KX_INPUT_JUST_RELEASED” right now it does both. Anybody know what to do?

you better check status.

Hint:
It would be simpler to use a sensor [mouse sensor in button mode].

When there is just one sensor and True Level Triggering is disabled you can safely assume the controller is only executed when the sensor just switched evaluation state (either from False to True or from True to False).

OK, I will do that. Thanks!

If I was going to do it with python, how would I? I checked status and it said it can contain only input active and no input. Could you give me a example of how to make the mouse just activated?

i prefer vanilla bge’s way of inputs, its nice and easy. hopefully someone can help you with upbge, since i cant.


if bge.logic.mouse.events[bge.events.LEFTMOUSE] == bge.logic.KX_INPUT_JUST_ACTIVATED:
    #do stuff


import bge 

keyStates = bge.logic.mouse.events

# look up the state of a specific key:
leftMouseButtonState = keyStates[bge.events.LEFTMOUSE]

# evaluate the state and extract the information you want to know
isLeftMouseButtonPressed = (
    leftMouseButtonState == bge.logic.KX_INPUT_JUST_ACTIVATED or
    leftMouseButtonState == bge.logic.KX_INPUT_ACTIVE)
    
print( isLeftMouseButtonPressed )

as said it is much simpler with a sensor:


import bge
 

controller = bge.logic.getCurrentController()

mouseSensor = controller.sensors["left mouse button"]

isLeftMouseButtonPressed = mouseSensor.positive

print(isLeftMouseButtonPressed)

This does not only work for mouse buttons but for keyboard keys, joystick, messages, collision …

OK got it, thanks!