BGE not responding to python scripts properly


I am fairly new to the BGE and have been following various basic tutorials that have all led me to the same place in which I have a cube with dynamic physics with an always sensor linked to a python controller above a plane, and my script (which I added below).

The issue is:

  1. That in all the tutorials the cube continuously moves when using the applyMovement method, for mine it simply does one initial movement before the cube begins to fall.
  2. The cube does not react when I include keyboard interaction, or even print a statement to console when I do keyboard interaction. However, these works when I add a keyboard sensor logic brick.

There are no errors, other than ‘shaders not supported’ in the console. I have tried this on various builds of blender (older versions as for some reason when i hit p in more recent versions blender crashes) and the same results. I have checked my code over numerous times and it is very simple but here it is:

import bge

def main():

    cont = bge.logic.getCurrentController()
    player = cont.owner
    keyboard = bge.logic.keyboard

    player.applyMovement([0,0.5,0], True)
    if bge.logic.KX_INPUT_ACTIVE ==[]:
        print('up key')


Thankyou in advance,

Welcome to the forums :slight_smile:
The only reason I can think of is that your Always sensor isn’t set to True pulse.

What this does is make the script run every frame, thereby checking every frame for controller input and moving the object. The reason the keyboard sensor would have worked is because it would run the script every time the keyboard is active.

Oh that did it thanks!

I strongly suggest to read the BGE Guides that you can find in my signature. It will help you to understand how the BGE is processing.