I’m trying to simply make a cube move around with the WASD keys, and jump with the space bar. The problem is the jumping. The cube moves up but not back down and I dont know how to fix it :(. I’m using python because it is cleaner than logic bricks. Here is the file, can someone help?
I’ll also give you the script if you don’t want to download the file:
import bge
cont = bge.logic.getCurrentController()
def main():
servo = cont.actuators["move"]
walking = 10
jumping = 10
F = cont.sensors["F"]
B = cont.sensors["B"]
L = cont.sensors["L"]
R = cont.sensors["R"]
jump = cont.sensors["jump"]
stop = servo.linV = [0, 0, 0]
cont.activate(servo)
if F.positive == True and B.positive == False:
servo.linV = [0, walking, 0]
elif B.positive == True and F.positive == False:
servo.linV = [0, -walking, 0]
elif F.positive == False and B.positive == False:
stop
elif F.positive == True and B.positive == True:
stop
if L.positive == True and R.positive == False:
servo.linV = [-walking, 0, 0]
elif R.positive == True and L.positive == False:
servo.linV = [walking, 0, 0]
else:
stop
if F.positive and L.positive:
servo.linV = [-walking, walking, 0]
elif F.positive and R.positive:
servo.linV = [walking, walking, 0]
else:
stop
if B.positive and L.positive:
servo.linV = [-walking, -walking, 0]
elif B.positive and R.positive:
servo.linV = [walking, -walking, 0]
else:
stop
if jump.positive:
servo.linV = [0, 0, jumping]
if jump.positive and F.positive:
servo.linV = [0, jumping, jumping]
if jump.positive and B.positive:
servo.linV = [0, -jumping, jumping]
if jump.positive and L.positive:
servo.linV = [-jumping, 0, jumping]
if jump.positive and R.positive:
servo.linV = [jumping, 0, jumping]
if jump.positive and F.positive and L.positive:
servo.linV = [-jumping, jumping, jumping]
if jump.positive and F.positive and R.positive:
servo.linV = [jumping, jumping, jumping]
if jump.positive and B.positive and L.positive:
servo.linV = [-jumping, -jumping, jumping]
if jump.positive and B.positive and R.positive:
servo.linV = [jumping, -jumping, jumping]
main()
Attachments
untitled.blend (498 KB)