python. verry new.

hey i just learned the beginning of python today and i made this script the forward back words left and right keys all work. besides jump. the bulk of the script i used a tut for but i wanted to make a jump mod to see how well i could do XD not so well i guess. anyway i know this may be inconvenient but if anyone has a min or two maybe you could look at this script and tell me what i messed up? thanks and if anyone has good tuts on hand on how to use python that would be cool if you could post those anyway thanks.





if forward.isPositive():
if backward.isPositive():
walk= -speed
if turnleft. isPositive():
turn= rspeed
if turnright.isPositive():
turn= -rspeed
if jump.isPositive():
jump= Hight

motion.setLinearVelocity(0, walk, 0, 1)
motion.setLinV(0,0,jump,1 )

Hey! Glad you’re picking up Python!
For someone first starting out like yourself, I’d suggest running through the tutorial that comes with the Python manuals. The tutorial will teach you about Python syntax, standard declarations, flow control, etc. After that, I’d reccomend finding some existing blender scripts that do something like what you want and take them apart to see how they work. Be sure to do lots of little “throw away” test programs along the way, these are priceless in learning any programing language. Good luck!


I don’t know much about the BGE API, but you might try

motion.setLinearVelocity(0, 0,jump, 1)
instead of
motion.setLinV(0,0,jump,1 )

I am assuming that the lack of indentation on your if statements is an artifact
of posting since you say everything but the jump is working.

Hope this helps

There are some links to python resources in my sig (including the GameLogic API).

In terms of problems with your script, I don’t quite understand why you are setting LinV and LinearVelocity. To further diagnose problems with python scripts, run the script in the game engine and then inspect the diagnostic in the terminal. It will tell you where the script is crashing. If the script is not crashing, but isn’t producing the desired result, include some print comands to help diagnose the problem.