KX_INPUT_JUST_ACTIVATED not works on 2.65?

Hi,all!

I making TPS on BGE, but I found a problem:
KX_INPUT_ACTIVE is working, but KX_INPUT_JUST_ACTIVATED is not working.
Example, this code is calling by KX_Scene.pre_load:


if bge.logic.keyboard.events[bge.events.SPACEKEY] == bge.logic.KX_INPUT_JUST_ACTIVATED:
    print("SPACEKEY is just activated!") #Not working!
if bge.logic.keyboard.events[bge.events.SPACEKEY] == bge.logic.KX_INPUT_JUST_ACTIVE:
    print("SPACEKEY is now active!") #It works!

Did you face same problem?

pre_load what is that?

It sounds like by-passing the bge logic. Better run the code inside a Python controller triggered by a keyboard sensor (e.g. all keys).

Sorry, s/pre_load/pre_draw

I think “using keyboard sensor” is not smart.

For instance, cut scene playing on video game, key input is shut out.
If using keyboard sensor, I must write “If isCutScenePlaying == False:” to everywhere.

‘’’
I found alternatives. I use this for the time being.


if bge.logic.keyboard.events[bge.events.SPACEKEY] == bge.logic.KX_INPUT_ACTIVE:
    time += 1
else:
    time = 0

if time == 1:
    print("Just activated!")

‘’’

“Not smart”? What you mean with that?

You expect game logic to work outside of its context.
I recommend to rework your game design.

If booleanExpression == False:

Please check PEP#008 if that is good code :wink:


if bool == False: #too Bad
if not bool: #cool!

I’m understood.

and… I found more good game design, and it works well. Thanks!