Discuss Scratch

791973GO
New to Scratch
10 posts

Two-button inputs (Plus overlaying keys)

I'm making a fighting game and it requires a lot of multi-button inputs. So far, I only have created one of such attacks, and it's inconsistent when spammed, going between the input I want (hammer fist) and the move otherwise assigned to that button (cross). Is there a way to stop that…?

I also have a dash mechanic I want to implement, where the player double-taps their motion key to move quickly in one direction for a short period of time. How might I go about that?

Last edited by 791973GO (May 8, 2024 21:25:33)

Ricocorico
Scratcher
15 posts

Two-button inputs (Plus overlaying keys)

could you send the link of the project ?
Woodfur
Scratcher
100+ posts

Two-button inputs (Plus overlaying keys)

For the double-tap, you'll have to use a variable to keep track of whether the key was pressed recently or not. If the key is pressed and the variable is set, do the action; if the key is pressed and the variable isn't set, set it, wait some interval, and unset it.

I use this in https://scratch.mit.edu/projects/975061570/ in Stage under “when stage clicked” but it's got a few extra blocks because it also triggers something else when held down. I'll leave it to you to pare it down.

say (something dumb)
switch costume to [dabbing v]
791973GO
New to Scratch
10 posts

Two-button inputs (Plus overlaying keys)

https://scratch.mit.edu/projects/1015450201/editor
This is the project, for those who need it to give advice.
791973GO
New to Scratch
10 posts

Two-button inputs (Plus overlaying keys)

Also, @Woodfur, I tried the variable method and now all the character does is dash for forward movement. If you could look through the code and tell me “this this and this is wrong and/or not helping you achieve what you want, do this instead”, that'd be much appreciated.
Woodfur
Scratcher
100+ posts

Two-button inputs (Plus overlaying keys)

Seems like you still need to hit “share” on the project for it to be visible.

say (something dumb)
switch costume to [dabbing v]
Woodfur
Scratcher
100+ posts

Two-button inputs (Plus overlaying keys)

Never could figure out why your code wasn't working. But I replaced it with this and it seems to work now. Sorry I can't be more specific about what went wrong.

I will point out that “wait” blocks can't be shorter than 1 frame, 1/30th of a second, which is how long Scratch waits between repetitions of a loop anyway, so your multiple wait/move/wait/move blocks weren't buying you anything. For the same reason, an increment-per-frame counter is going to take forever to get to 1000, which can't have been helping. That doesn't explain why it wasn't counting at all though.

say (something dumb)
switch costume to [dabbing v]
791973GO
New to Scratch
10 posts

Two-button inputs (Plus overlaying keys)

Woodfur wrote:

Never could figure out why your code wasn't working. But I replaced it with this and it seems to work now. Sorry I can't be more specific about what went wrong.

I will point out that “wait” blocks can't be shorter than 1 frame, 1/30th of a second, which is how long Scratch waits between repetitions of a loop anyway, so your multiple wait/move/wait/move blocks weren't buying you anything. For the same reason, an increment-per-frame counter is going to take forever to get to 1000, which can't have been helping. That doesn't explain why it wasn't counting at all though.
My counter seems to be working fine on my end now. I had something messed up in my main controls script. Now I'm just confuzzled why it doesn't show up on search results.

Last edited by 791973GO (May 13, 2024 11:10:49)

Powered by DjangoBB