Discuss Scratch

THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

I´m making a platformer in scratch and it has my OC in it with a walking cycle but when I try to walljump it glitches INTO the platformer and when I try jumping it falls down even more. I don´t know how to use and get a hitbox!

Last edited by THECRABGOD (May 19, 2020 14:05:43)

ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

To use a hitbox, make a another costume in that sprite that has the same dimensions as the original costume and name that costume hitbox. Then do the following code
whenclickedforeverswitchcostumetohitbox. . .platforming codeswitchcostumetoOC
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

Yeah, but I have a walking animation so how does that work?

Last edited by THECRABGOD (May 19, 2020 14:09:37)

ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

Can you share the project so I can see what I am working with?
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

Well all of your costumes have a range of 75-79 x 121-128, so you have 2 options. Either make a hitbox for every costume and name the costume something like hitboxJump or something. Or just create one hitbox that is bigger or the same size as all of them. For example one that is 79 x 128.
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

???
ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

If you look at all of the costumes for your sprite, they all have a number and a size on them.
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

Yeah but then its just gonna be 1 thing.
ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

Then you got it… just make sure to switch to the hitbox costume before your platforming script and then switch to your character and your good to go…
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

But then how do I get the walking animation?
ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

Use a variable and use it to step the animation. For example:
whenclickedifXYelocity>0thenchangeAnimation Stepby1
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

I´m still confused tho… I dont use that for my animation. I use this:
ifkeypressed?thenswitchcostumetowaitsecsswitchcostumetowaitsecsswitchcostumetowaitsecselseswitchcostumeto

Last edited by THECRABGOD (May 19, 2020 14:45:18)

ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

??? Share the project again so I can see.
THECRABGOD
Scratcher
22 posts

How do I use a hitbox in a platformer?

ScratchinMyWay
Scratcher
100+ posts

How do I use a hitbox in a platformer?

Here I remixed it https://scratch.mit.edu/projects/396992399/ I don't think you should use the jump or the fall costume because they just don't seem to fit in your game…
Locomule
Scratcher
1000+ posts

How do I use a hitbox in a platformer?

Using Wait blocks for platformer animations can be a real pain. Here is a recent YouTube tutorial I made skipped ahead to the part where I setup the player walk animation speed using a variable and the Scratch timer

https://youtu.be/cDR7MX6mSiM?t=1022

Powered by DjangoBB