Discuss Scratch

BossRushFanatic
New Scratcher
54 posts

How to make double jump mechanic?

So I'm adding some kind of a double jump in a project I'm making and was wondering how can I implement it to my project? I've tried a couple of stuff but it hasn't worked or hasn't worked as I wanted it to work. I have a variable that turns into yes whenever your characters jumps and wanted to tried something like this:

if <[InAir?] = [Yes]> then
if <key [z v] pressed?> then
set [Yspeed v] to [10]
end
end

Unfortunately this code gets overwritten because the project thinks I already pressed z to jump cuz it activates the “InAir” variable immediately your character leaves the floor making it so it only jumps. Is there a way I can fix that? Or other ways I could try? (Also if you want more information about the kind of double jump I want to make I'm working on a Kirby fan game and wanted it so you can jump unlimited like in the games)
Koamodo975
Scratcher
1000+ posts

How to make double jump mechanic?

thank god you're doing kirby style
Aight here we go:
First off, it'd be nice if you share the project so I can see the rest of the code and figure out a solution that's compatible.
Second, working without context, here's how I'd do this.
For starters, add a new var(jumpcooldown or smth). Inside the air check code, check to see if jumpcooldown is less than one; if so, set it to a number (say, 10) and jump. In a separate script, change jumpcooldown by -1 if it's greater than zero; this should give you the basics. I haven't played Kirby in a long time, so sorry if I missed anything about the jumps.
BossRushFanatic
New Scratcher
54 posts

How to make double jump mechanic?

Koamodo975 wrote:

thank god you're doing kirby style
Aight here we go:
First off, it'd be nice if you share the project so I can see the rest of the code and figure out a solution that's compatible.
Second, working without context, here's how I'd do this.
For starters, add a new var(jumpcooldown or smth). Inside the air check code, check to see if jumpcooldown is less than one; if so, set it to a number (say, 10) and jump. In a separate script, change jumpcooldown by -1 if it's greater than zero; this should give you the basics. I haven't played Kirby in a long time, so sorry if I missed anything about the jumps.
It worked! Thank you so much!
BossRushFanatic
New Scratcher
54 posts

How to make double jump mechanic?

Koamodo975 wrote:

thank god you're doing kirby style
Aight here we go:
First off, it'd be nice if you share the project so I can see the rest of the code and figure out a solution that's compatible.
Second, working without context, here's how I'd do this.
For starters, add a new var(jumpcooldown or smth). Inside the air check code, check to see if jumpcooldown is less than one; if so, set it to a number (say, 10) and jump. In a separate script, change jumpcooldown by -1 if it's greater than zero; this should give you the basics. I haven't played Kirby in a long time, so sorry if I missed anything about the jumps.
Wait nvm it sometimes works and sometimes it doesn't. Ok I can finally do double jumping but unfortunately the problem of the game detecting Kirby as floating immediately after leaving the floor instead of when double jumping is still intact. Anyway I could fix that?
Koamodo975
Scratcher
1000+ posts

How to make double jump mechanic?

BossRushFanatic wrote:

Wait nvm it sometimes works and sometimes it doesn't. Ok I can finally do double jumping but unfortunately the problem of the game detecting Kirby as floating immediately after leaving the floor instead of when double jumping is still intact. Anyway I could fix that?

Do you have a airborne-checking variable? If not, you could create a variable (I'ma call it airborne) that sets itself to 0 when you're on the ground and goes up when you're not. If airborne is greater than a certain number, say 5, when the jump key is pressed, it shouldn't detect the first jump as an airjump. You're probably gonna have to tweak the threshold for airborne so that it only misses the first jump, instead of the second or third.
BossRushFanatic
New Scratcher
54 posts

How to make double jump mechanic?

Koamodo975 wrote:

BossRushFanatic wrote:

Wait nvm it sometimes works and sometimes it doesn't. Ok I can finally do double jumping but unfortunately the problem of the game detecting Kirby as floating immediately after leaving the floor instead of when double jumping is still intact. Anyway I could fix that?

Do you have a airborne-checking variable? If not, you could create a variable (I'ma call it airborne) that sets itself to 0 when you're on the ground and goes up when you're not. If airborne is greater than a certain number, say 5, when the jump key is pressed, it shouldn't detect the first jump as an airjump. You're probably gonna have to tweak the threshold for airborne so that it only misses the first jump, instead of the second or third.
Got it! Thank you so much I will let you know how it goes! ^^
BossRushFanatic
New Scratcher
54 posts

How to make double jump mechanic?

Koamodo975 wrote:

BossRushFanatic wrote:

Wait nvm it sometimes works and sometimes it doesn't. Ok I can finally do double jumping but unfortunately the problem of the game detecting Kirby as floating immediately after leaving the floor instead of when double jumping is still intact. Anyway I could fix that?

Do you have a airborne-checking variable? If not, you could create a variable (I'ma call it airborne) that sets itself to 0 when you're on the ground and goes up when you're not. If airborne is greater than a certain number, say 5, when the jump key is pressed, it shouldn't detect the first jump as an airjump. You're probably gonna have to tweak the threshold for airborne so that it only misses the first jump, instead of the second or third.
It worked! It was a complete success! Thank you SO MUCH!! Hope you have an amazing day!
Koamodo975
Scratcher
1000+ posts

How to make double jump mechanic?

BossRushFanatic wrote:

Koamodo975 wrote:

BossRushFanatic wrote:

Wait nvm it sometimes works and sometimes it doesn't. Ok I can finally do double jumping but unfortunately the problem of the game detecting Kirby as floating immediately after leaving the floor instead of when double jumping is still intact. Anyway I could fix that?

Do you have a airborne-checking variable? If not, you could create a variable (I'ma call it airborne) that sets itself to 0 when you're on the ground and goes up when you're not. If airborne is greater than a certain number, say 5, when the jump key is pressed, it shouldn't detect the first jump as an airjump. You're probably gonna have to tweak the threshold for airborne so that it only misses the first jump, instead of the second or third.
It worked! It was a complete success! Thank you SO MUCH!! Hope you have an amazing day!
YW, glad it worked!
tmaclock
Scratcher
16 posts

How to make double jump mechanic?

I want something platformer style and I need help with double jumping
TopPenguin677
Scratcher
1 post

How to make double jump mechanic?

can't help ya there bud

Powered by DjangoBB