strange problem:(

So here’s my problem, I have this script that I use for controls, it works perfectly, but then I changed it so that you could use the arrow keys or “WASD” Keys, and now the movement still works, but everything else thats supposed to happen when you press the key doesn’t. I hope that makes sense.

Here’s the code before I changed it:


if key == bge.events.WKEY:           
     Y = movementSpeed
     if degreeX < rotationAmount:
          lightMotion.applyRotation ([0.01, 0, 0])
          degreeX += 1

and the code after I changed it:


if key == bge.events.WKEY or key == bge.events.UPARROWKEY:
     Y = movementSpeed
     if degreeX < rotationAmount:
          lightMotion.applyRotation ([0.01, 0, 0])
          degreeX += 1

the problem is that it works perfectly for the “WKEY”, but completely skips the second if statment if you press “UpArrow”. Any Ideas?

Hmm… that’s weird, I don’t think it should be doing that. In your first script, the statement “Y = movementSpeed” is on the same line as the if clause. Maybe that causes weird behavior and you should move it to its own line? Also, check the console for any errors.

sorry no that was just my own typing error while typing out this post, I fixed the code in the first post to how it actually is in my file.
There isn’t any errors in the console.

Now you have an inconsistency in indentation between the two code snips.:wink: Probably just another typo in posting the code, but other that that I have no clue, sorry.

Thanks anyways, ya that was a typo.

is there somewhere else in your code where WKEY does something that UPARROWKEY does not?

Nope the only other spot I use the WKEY is for if its not pressed as in:


if not keyboard.getKeyStatus(bge.events.WKEY) == bge.logic.KX_INPUT_ACTIVE or keyboard.getKeyStatus(bge.events.UPARROWKEY) == bge.logic.KX_INPUT_ACTIVE:
        if degreeX > 0:
            degreeX -= 1
            lightMotion.applyRotation ([-0.01, 0, 0])

What are the conditions for this supposed to be? The combination of the ‘not’ and the ‘or’ might not be evaluated the way that you think it is. ‘not’ evaluates before ‘or’. Your condition would be more clearly written as:



if keyboard.getKeyStatus(bge.events.WKEY) != bge.logic.KX_INPUT_ACTIVE or keyboard.getKeyStatus(bge.events.UPARROWKEY) == bge.logic.KX_INPUT_ACTIVE:

Did you really intend for this:


if not (keyboard.getKeyStatus(bge.events.WKEY) == bge.logic.KX_INPUT_ACTIVE or keyboard.getKeyStatus(bge.events.UPARROWKEY) == bge.logic.KX_INPUT_ACTIVE):

Yes thank you, it was supposed to be “and not” not “or not”:), I appreciate the help.