EDIT (question is still valid though) I discovered that the issue was not the code, it was the object. I had Character physics on my cube, and it needed to be Dynamic.

Still, I would like to know how to fix the issue, since I prefer Character physics.

So I'm going through a basic tutorial in which I need to apply forward momentum to a cube. Here's my Python script.

import bge

def main():

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

key = bge.logic.keyboard
activekey = bge.logic.KX_INPUT_ACTIVE
releasedkey = bge.logic.KX_INPUT_JUST_RELEASED
_w = key.events[bge.events.WKEY]
_a = key.events[bge.events.AKEY]
_s = key.events[bge.events.SKEY]
_d = key.events[bge.events.DKEY]
_shft = key.events[bge.events.LEFTSHIFTKEY]
w = activekey == _w
a = activekey == _a
s = activekey == _s
d = activekey == _d
shft = activekey == _shft
wrel = releasedkey == _w
arel = releasedkey == _a
srel = releasedkey == _s
drel = releasedkey == _d
spd = .1
mmt = 100

if shft:
    spd = spd*2
if w:
    player.applyMovement((0, spd, 0), True)
if wrel:
        player.applyForce((10000,0,0), True)
if s:
    player.applyMovement((0, -spd, 0), True)
if a:
    player.applyMovement((-spd, 0, 0), True)
if d:
    player.applyMovement((spd, 0, 0), True)


I'm focusing on this line:

if wrel:
    player.applyForce((10000, 0, 0), True)

Whenever I play this, my cube moves, but then stops instantly. I tested the wrel variable to make sure it worked by:

A. using a print function and checking the command line (successful)
B. using an applyMovement function (successful)

But when I change applyMovement to applyForce, it yields nothing.

What am I doing wrong?


1 Answer 1


I tested your script and found that character physics don`t have mass attribute as rigid body and dynamic does, and to apply force the object need mass attribute to work. So you will need to work with rigid body or dynamic.

  • $\begingroup$ Also i try to inherit the object to add mass attribute wich still not work in character physics but work for rigid body and dynamic (but they already have the attribute so just change the value). $\endgroup$ Apr 26, 2017 at 6:38
  • $\begingroup$ Thanks, I found the situation really confusing. Knowing this'll help me in the long run! $\endgroup$
    – Endvisible
    Apr 26, 2017 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .