Ok, so I was following Social’s beginner BGE tutorial, and it’s all fine and dandy, but then it gives me an example of how to improve upon the game, which is by adding a jump feature. I was able to do that, but next i want to make it so u can only jump once. Here’s the script i have so far:
cont = GameLogic.getCurrentController() own = cont.getOwner() #Sensors forward = cont.getSensor("Up") backward = cont.getSensor("Down") left = cont.getSensor("Left") right = cont.getSensor("Right") jump = cont.getSensor("Space") #Actuators motion = cont.getActuator("motion") #Process speed = 0.07 rspeed = 0.02 height = 5 walk = 0 turn = 0 playerjump = 0 if forward.isPositive(): walk = speed if backward.isPositive(): walk = -speed if left.isPositive(): turn = rspeed if right.isPositive(): turn = -rspeed if jump.isPositive(): playerjump = height motion.setDLoc(walk, 0, 0, 1) motion.setDRot(0, 0, turn, 1) motion.setLinearVelocity(0, 0, playerjump, 1) GameLogic.addActiveActuator(motion, 1)
and that all works fine, but you can jump as many times as you want, and I want to change it. I tried looking at the official documentation, but i couldnt make heads or tails of it, so i came here.