Hello all - simple problem, I just don’t seem to know how to fix it.
Ok, so when I use my script it doesn’t continuously applyMovement()
For example, when I hold the ‘w’ key it won’t CONTINUOULY go forward 0.1 blender units, it just goes once. So I’m left to repeatedly press the key again and again to go forward. How do I fix this ? Note: I know I can just use an actuator, but I don’t want to. Please, help me with my way around this. Here is my script:
import bge
from bge import logic
from bge import events
cont = logic.getCurrentController()
obj = cont.owner
collision = cont.sensors["Collision"]
key = logic.keyboard.events
WKEY = key[events.WKEY]
AKEY = key[events.AKEY]
SKEY = key[events.SKEY]
DKEY = key[events.DKEY]
SPACEKEY = key[events.SPACEKEY]
yMove = 0.0
xMove = 0.0
if AKEY == 3:
xMove = 0.0
if DKEY == 3:
xMove = 0.0
if AKEY == 2:
xMove = -0.1
if DKEY == 2:
xMove = 0.1
if AKEY == 1:
xMove = -0.1
if DKEY == 1:
xMove = 0.1
if WKEY == 3:
yMove = 0.0
if SKEY == 3:
yMove = 0.0
if WKEY == 2:
yMove = 0.1
if SKEY == 2:
yMove = -0.1
if WKEY == 1:
yMove = 0.1
if SKEY == 1:
yMove = -0.1
if SPACEKEY == 1 and collision.positive:
obj.applyForce([0.0, 0.0, 300], 1)
obj.applyMovement([xMove, yMove, 0.0], 1)