Discuss Scratch
- Discussion Forums
 - » Help with Scripts
 - » how do i make hit boxes
        
         
- ametrine_
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
how do i make hit boxes
here's the basic idea:
                        
                        
                    foreverdoing this will make the part of the sprite that actually collides with surroundings the “hitbox” costume, rather than the original costume
switch costume to [hitbox v] // a rectangular costume in the same position as the player costume
check if touching stuff
switch costume to [player v]
end
- 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
here's the basic idea:this DOES work, but you can also doforeverdoing this will make the part of the sprite that actually collides with surroundings the “hitbox” costume, rather than the original costume
switch costume to [hitbox v] // a rectangular costume in the same position as the player costume
check if touching stuff
switch costume to [player v]
end
when @greenflag clicked::hat eventsEdit: Please note I have not tested this yet.
forever
go to (sprite v)//the sprite you want it to hitbox
set (ghost v) effect to [100]
end
Last edited by Create-Scratch101 (Nov. 14, 2024 20:14:45)
- ametrine_
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ 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.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
this DOES work, but you can also dothis 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)when @greenflag clicked::hat eventsEdit: Please note I have not tested this yet.
forever
go to (sprite v)//the sprite you want it to hitbox
set (ghost v) effect to [100]
end
- Whatdidyousay245
 - 
                            
						
						
                            Scratcher
                        
						
						 
98 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.it will not flash the costume unless you have a repeat loop in there as each loop lasts 1 frame
foreverit 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)
move (1) steps
just some random stuff, like alot :: operators
end
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
when [1] key pressed
if <touching [ player] ?> then
(switch costumes)
if <touching [dummy] ?> then
(switch costumes)
end
end
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
Thankametrine_ 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 frameforeverit 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)
move (1) steps
just some random stuff, like alot :: operators
end
it will not flash, even if you put a hide and show at each end of the script
- Ym2612
 - 
                            
						
						
                            Scratcher
                        
						
						 
98 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
player controlled code
                        
                        
                    hitbox code
when green flag clicked
set [ghost v] effect to (100)
forever
go to [playerconrolledsprite v]
if <touching [damaging things v] ?> then
broadcast [just got damaged v]
end
end
player controlled code
when I receive [just got damaged v]
do the damage code
- -starlit_puma-
 - 
                            
						
						
                            Scratcher
                        
						
						 
51 posts
how do i make hit boxes
yall idk how to make hitboxes i need helpI would suggest this video (this link will take you out of Scratch)
- Discussion Forums
 - » Help with Scripts
 - 
            » how do i make hit boxes 
         








