First steps in Python. A problem with movement and rotation

Hello

My code is from this video


import bge




def main():


    cont = bge.logic.getCurrentController()
    player = cont.owner
    
    keyboard = bge.logic.keyboard
    
    wKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.WKEY]
    sKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SKEY]
    dKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DKEY]
    aKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.AKEY]
    
    wKey_rel = bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.WKEY]    
    
    movSpeed = 0.1
    rotSpeed = 3
    drift = 100


    # Translation
    if wKey:
        player.applyMovement( ( 0, movSpeed, 0 ), True )
        
    elif sKey:
        player.applyMovement( ( 0, -movSpeed, 0 ), True )
        
    elif wKey_rel:
        player.applyForce( ( 0, drift, 0 ), False )
    
    # Rotation    
    if dKey:
        player.applyRotation( ( 0, 0, -rotSpeed ), False )
        
    elif aKey:
        player.applyRotation( ( 0, 0, rotSpeed ), False )


main()

This is my video for demonstration of my problem

This is my blend file

I upload blend on webpage but I cannot move by WASD. Why? http://notes.orgfree.com/bge_movementByHaher269.html

Thank you in advance

I added link on video where I took code above

This code I like more (from here):


import bge


controller = bge.logic.getCurrentController()
player = controller.owner


keyboard = bge.logic.keyboard.events
W = keyboard[bge.events.WKEY]
S = keyboard[bge.events.SKEY]
A = keyboard[bge.events.AKEY]
D = keyboard[bge.events.DKEY]


speed = 0.3
rotSpeed = 0.1


if W > 0:
    player.applyMovement( ( 0, speed, 0 ), True )
    
if S > 0:
    player.applyMovement( ( 0, -speed, 0 ), True )
    
if A > 0:
    player.applyRotation( ( 0, 0, rotSpeed ), True )
    
if D > 0:
    player.applyRotation( ( 0, 0, -rotSpeed ), True )

But I don’t know why the code from my first post doesn’t work nomaly

The code was fine these were the only changes.


# This should not be 3, otherwise it rotates super fast
rotSpeed = 0.1 
# This means that when you release the key the object moves a bit
# If this what you want to do no problem then.
# elif wKey_rel:
#    player.applyForce( ( 0, drift, 0 ), False )

I don’t know which browser plugin this is, Blend4Web?
Perhaps you must gain a deep look at the documentation to see if there’s an
important setting to enable or even ask the developers of the plugin, to see
if they know something about this problem.

This should not be 3, otherwise it rotates super fast

I understood, thank you!

I don’t know which browser plugin this is, Blend4Web?

I use Burster, but Blend4Web look better