Discuss Scratch

Unique-codes
Scratcher
3 posts

how do i make hit boxes

yall idk how to make hitboxes i need help
ametrine_
Scratcher
1000+ posts

how do i make hit boxes

here's the basic idea:
foreverswitchcostumetohitbox a rectangular costume in the same position as the player costumecheckiftouchingstuffswitchcostumetoplayer
doing this will make the part of the sprite that actually collides with surroundings the “hitbox” costume, rather than the original costume
Unique-codes
Scratcher
3 posts

how do i make hit boxes

Thanks
bsteichman
Scratcher
500+ posts

how do i make hit boxes

ametrine_ is correct, however i would put the hiding, showing, and hitbox detection code in its own custom block set to “run without screen refresh” because you don't want it to flash the hitbox costume.

Last edited by bsteichman (Nov. 14, 2024 21:25:25)

Create-Scratch101
Scratcher
500+ posts

how do i make hit boxes

ametrine_ wrote:

here's the basic idea:
foreverswitchcostumetohitbox a rectangular costume in the same position as the player costumecheckiftouchingstuffswitchcostumetoplayer
doing this will make the part of the sprite that actually collides with surroundings the “hitbox” costume, rather than the original costume
this DOES work, but you can also do

whenclickedforevergotospritethe sprite you want it to hitboxsetghosteffectto100
Edit: Please note I have not tested this yet.

Last edited by Create-Scratch101 (Nov. 14, 2024 20:14:45)

ametrine_
Scratcher
1000+ posts

how do i make hit boxes

bsteichman wrote:

ametrine_ is correct, however i would put the hiding, showing, and hitbox detection code in its own custom block set to “run without screen refresh” because you don't want it to flash the hitbox costume.
you only need to do this if there's any blocks that wait until the next frame before progressing the code
ametrine_
Scratcher
1000+ posts

how do i make hit boxes

Create-Scratch101 wrote:

this DOES work, but you can also do

whenclickedforevergotospritethe sprite you want it to hitboxsetghosteffectto100
Edit: Please note I have not tested this yet.
this works, but you have to make the hitbox sprite behind the sprite it's hitboxing (so its goes to the other sprite after it moves)
Whatdidyousay245
Scratcher
86 posts

how do i make hit boxes

bsteichman wrote:

ametrine_ is correct, however i would put the hiding, showing, and hitbox detection code in its own custom block set to “run without screen refresh” because you don't want it to flash the hitbox costume.
it will not flash the costume unless you have a repeat loop in there as each loop lasts 1 frame

forevermove1stepsjustsomerandomstuff,likealot
it wouldn't be slow because there's a lot of code, but instead because its all happening each frame. even if you removed the stuff it would be the same speed (if this stuff didn't affect your fps)
it will not flash, even if you put a hide and show at each end of the script
Unique-codes
Scratcher
3 posts

how do i make hit boxes

when1keypressediftouching player?thenswitchcostumesiftouchingdummy?thenswitchcostumesendend





some code for an attack fill custom blocks with switch costumes and pause blocks with no spaces also

Last edited by Unique-codes (Nov. 19, 2024 20:49:05)

NextMoveSudden
Scratcher
8 posts

how do i make hit boxes

Whatdidyousay245 wrote:

bsteichman wrote:

ametrine_ is correct, however i would put the hiding, showing, and hitbox detection code in its own custom block set to “run without screen refresh” because you don't want it to flash the hitbox costume.
it will not flash the costume unless you have a repeat loop in there as each loop lasts 1 frame

forevermove1stepsjustsomerandomstuff,likealot
it wouldn't be slow because there's a lot of code, but instead because its all happening each frame. even if you removed the stuff it would be the same speed (if this stuff didn't affect your fps)
it will not flash, even if you put a hide and show at each end of the script
Thank
Ym2612
Scratcher
66 posts

how do i make hit boxes

what I do is make a separate sprite, set ghost to 100 and make it go to the player controlled sprite. Then whenever the sprite is touched by anything damaging, it broadcasts a message, which the player controlled sprite picks up and starts the “damage” sequence of code


hitbox code
whenclickedsetghosteffectto100forevergotoplayerconrolledspriteiftouchingdamaging things?thenbroadcastjust got damaged

player controlled code
whenIreceivejust got damageddothedamagecode
-starlit_puma-
Scratcher
44 posts

how do i make hit boxes

Unique-codes wrote:

yall idk how to make hitboxes i need help
I would suggest this video (this link will take you out of Scratch)

Powered by DjangoBB