Charge Jump? on a Joystick?

Hi people,

I’ve done a lot of browsing to find out how this is done…and I got nothing.

How do you do a charge jump?

I have the animations, I know how to make the character jump. But how to you make the character hold it, until the button is released? (on a joystick)

Also…for the jump height to increase for how long the button was held?

Thank you.

The keyboard, mouse and Joystick sensors fire a True Pulse to the controller if the sensed button is just pressed and a False pulse if the button is just released. See Sensors: A word on Pulses.

To measure how long a button is pressed you can

  • count each frame as long as the button is pressed (use the True Pulse mode), check the value whn the button is released.

Property int or float “count”, 0
button sensor True pulse
-> and -> property acutator count + 1
-> whatever you want to do; The property “count” contains the number of frames the button was holded. Reset it to zero when not needed!

  • use a timer property. Set it to 0 when the button is just pressed. Check its value when the button is just released.

property timer “time” 0.0
button sensor (no pulses)
-> and -> property actuator time = 0
-> whatever you want to do; The property “time” contains the time since button press till now (be aware the timer will continue with counting

I believe the easiest way to do this with python. note that i have not transitioned into 2.55, so the scripts that im posting are 2.49b scripts.
here is a .blend(for 2.49) that does what i think is exactly what you want.
NOTE!: when setting this up the names of the sensors, actuators, and properties must be exactly the same as the demo.

also by changing the “adjust” property you can make the cube(player) jump higher or not as high.(the higher the number the higher the cube jumps)

also note that this uses the keyboard(sense i done have a joystick)
but if you know some more python you can probably do close to the same thing i did, except for with the joystick, i could try and make the code for a joystick but i would have no way of testing it.

Hope this helps!!

Attachments

proportional jump(keyboard).blend (154 KB)

Thank you all for your responses, I’ll try both methods to see which one I like. I think I may go with the python rout, but I’m a bit more adept with logic bricks, so I’ll experiment. Also the break down on the sensor pulses is going to be very useful in the future.

You both have helped me greatly.

Thanks.

Here you have an example. It uses the timer method and has 3 Power levels.
It is pure python. I think you can easily extend it with more levels.
If you want non-discretionary power you need to use a python script.
Let me know if you need it.

powerJumpDemo.blend (332 KB)

Yes! this is easy now, Thank you again Monster