running 'and' jumping
Blitz3D Forums/Blitz3D Programming/running 'and' jumping
| ||
just wondered what the best way to go with this is. I would like it so that when you are running then you jump, a new sequence plays , not just the run cycle or the standing jump cycle I tried something like if keydown(200) and keyhit(184) runflag=0 do run jump whatever but it didn't seem to work. what happens is it plays part of the first frame then freezes/ returns back to the run cycle |
| ||
something like if OnGround = true if not CharState = TakenHit if keyhit(JumpKey) CharState = jump endif endif endif if JumpFlag = 0 if CharState = jump if not animseq(yourjumpanim) translateentity char,0,5,0 ; you should make another ;function where the longer you hold the higher you jump ;but the gets a bit more complex animate char ; do the jump anim etc JumpFlag = 1 endif endif endif ;then do a check for when the entity lnads and if the state ;is jumping add in a landing animation and set the state to ;landing. i have it working good in my engine with variable height based on button length held. It's different to this but the principle is the same. |
| ||
Thanaks,I did something similar, but the problem is that the run flag won't turn off while I am pressing the jump key whilst running ie running jump. imagine that if you are running and you take off on your right leg, the run should tween from that to the running jump animation seamlessly. |
| ||
perhaps if I post the wip , someone can take a look and give me a hand. its almost working , just the run jump only plays the first frame then sticks and the standing jump doesn't default back to idle after finishing aprt from that it's coming along nice |
| ||
The best idea is to set a "mode" for your character. So when you press the jump key you change his "mode" to "jump" then your code will never call the normal "running" code. So your main control loop would be something like this: select PLAYERmode case 0 DoPlayerNormal() case 1 DoPlayerJumping() end select The DoPlayerNormal function will be checking for keys and making him run. When the jump key is pressed you change the PLAYERmode to 1 and then the DoPlayerJumping function will be called and in that you have no check for the jump key been pressed. Look in the code archives for my Manic Miner. Its 2D but the logic is still the same. |
| ||
I have changed the 'enemy' over to select case, but have n't done it for the player yet. i suppose I should. i just wanted to fix the problem as it stood, because all the player controls are inside the 'update player' function, which seemed quit manageable , but its been a bit problematic.(learned a lot though) I will check out manic miner, thanks |