jumping like a kangoroo...help

hey, i’ve added jump ability to my 1st person setup (actually the walkthrought template) using keyboard sensor and ray sensor (-z) linked to an AND controller to a motion actuator with force set in z axis. The problem is if i press my key and HOLD it down, when my camera go down and touch the ground again then it jumps AGAIN…so how could i fix this?

another question, i have a variable set to -1 could i set it to 1 using properties or something else and bind to a toggle key on the keyboard? this is to invert the mouse with a key at runtime

EDIT: basically, all i want to know is if there is a way to execute an action only 1 time when a key is pushed and how to make a toggle key for a property

can a keyboard sensor look if a key isn’t pushed?..so i could make a “run” key. but i’m stuck with the jumping problem

i have tryed with a python script attached to a keyboard sensor named “shiftkey”, “maxspeed” is a property

ga = GameLogic
co = ga.getCurrentController()
running = co.getSensor("shiftkey")

if running.isPositive():


guess what? it doesn’t work :frowning:

Ok, to solve your jump problem.

Since you already know how to hook up the logic bricks to make your character jump I won’t go through that.

I assume that to have your character jump you have this setup.
Keyboard(Space) -> AND -> Motion Actuator(forceZ=10)

  1. Add property “Jumped”, make it a boolean that’s set to false.
  2. Add a property sensor that checks to see if property “Jumped” is false (connect that sensor to the same AND controller that Keyboard(Space) is connected to).
  3. Add a property actuator that assigns the value True to the property “Jumped” (Connect this actuator the same AND controller that Motion Actuator(forceZ=10) is connected to).

So when you jump, the character jumps and the property “Jumped” gets set to True and stays True. The 2nd time around when you press space nothing happens because “Jumped” is not equal to false.

Hope this was what you were looking for.

Jason Lin

yeah this works, my camera jump only one time if i push my jump key…but how if i want to jump again? i can’t because the property “jumped” is set to true
my problem was if i hold down my jump key then my camera jump endlessly…and i don’t want that. but i want to be able to jump again if i press my jump key a second time.

i think that if the “jumped” property is “true” and that the jump key is NOT pressed then the “jumped” value should return to “false” so i can jump again. so how to make this?

EDIT: i managed to get it working by using a “readytojump” property with the “jump” keyboard sensor. the property is driven by python and turned 1/0 depending on the “jump” key is pressed or not.
yeah…python is quite fun when it’s working :smiley:

It is very very simple.

Add another keyboard sensor for the SPACE key, but with the ‘INV’ button toggle.
This will trigger the attached controller when you release the key. Then add an actuator to change your “jumped” property back to False.


ok i will try that too but since i got it working with python…it’ll be to improve my knoledge of logic bricks :smiley:
so if you press the “inv” button it correspond an “on release” function like in flash…that will be usefull

I’m not sure that it is a ‘on release’ activation.

I think that it is a negation. In this case means that the space key is not pressed.

In fact it would be good to make it run in pulse mode, once every second or less.

But for your problem it works the same: as long as you keep SPACE down the “jumped” property will stay True, going FALSE otherwise.