A
arirish
Guest
I'm pretty happy with how my movement is shaping up, but one thing I can't get my head around is variable jumping. I have tried, failed, moved on to something else, then come back to it 4 or 5 times already. I've studied various tutorials and videos, and looked at old forum posts on the subject, and nothing seems to work. I suspect it's to do with the way my FSM is set up.
In my IdleState script, here's the code for jumping:
kjump is keyboard_check_pressed(jumpbutton). StateSwitch switches to the JumpState script, which right now is an utter mess having been through countless tweaks and overhauls, but looks like this:
I see WHY this doesn't work, but I don't see what I can do to make it work. Basically I need it so that a tap of the jump key gives a jump of about 75% maximum, while holding it gives you a higher jump. I tried 'vsp=-(jmpspd/2)' to give the player a boost of half the regular jump, hoping the 'kjumpheld' line would do the rest, even if it would look a bit odd, but it just gave me a very stunted jump. I'm lost.
In my IdleState script, here's the code for jumping:
Code:
if kjump && jumps>0 {
vsp=-jmpspd;
jumps-=1;
StateSwitch("Jump");
}
Code:
if kjumpheld {while vsp<-jmpspd {vsp-=1}}
if keyboard_check_released(global.controls[4])
{vsp*=0.5}
if vsp>0 {StateSwitch("Fall");}