Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a Hit box?
- Adamm386
- New Scratcher
9 posts
How do I make a Hit box?
How do I make a proper hit box?
Last edited by Adamm386 (March 28, 2024 20:19:21)
- PhiPhenomenon
- Scratcher
500+ posts
How do I make a Hit box?
It's in the name, you make a box that detects if things hit it. In a nutshell, you would put your normal movement controls in the hitbox (like WASD). Then it would check if it was touching anything, like walls or enemies. If you want to make graphics for the character, you can set the ghost effect of the hitbox to 100 and make a new sprite follow the hitbox.
- PhiPhenomenon
- Scratcher
500+ posts
How do I make a Hit box?
Sure. Can you please show me, like in commands?
Here we have Scratch Cat and its hitbox, which is in red.
Here's the code that I use to move the hitbox around:
when green flag clicked
forever
if <key [w v] pressed?> then
change y by (10)
end
if <key [s v] pressed?> then
change y by (-10)
end
if <key [d v] pressed?> then
change x by (10)
end
if <key [a v] pressed?> then
change x by (-10)
end
end
I always want Scratch Cat to follow my hitbox because that's the costume I want to show the player:
when green flag clicked
forever
go to [hitbox v]
end
Usually, we don't want to see the hitbox, so we can set the ghost effect to 100. That makes sure the hitbox can still interact with other sprites, but you can't see it:
set [ghost v] effect to (100)
- Discussion Forums
- » Help with Scripts
- » How do I make a Hit box?