Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a working hitbox?
- dogefan91
-
14 posts
How to make a working hitbox?
the thing is, i have everything done, the acceleration, the physics, but the one thing i cant do is have collision that isnt clanky and bad.
- G157
-
100+ posts
How to make a working hitbox?
Make the opposite force of the hitbox same with the player, then make it run without screen refresh. You can do this by making a custom block for it:
(this is assuming it's supposed to not go through the block)
then

make sure that the custom block is running without screen refresh:
(this is assuming it's supposed to not go through the block)
then
You can get more complicated than this, but this is how I mainly do it

- dogefan91
-
14 posts
How to make a working hitbox?
Sure, Thanks for the info, im making a SCROLLING PLATFORMER, not a screen by screen platformer. Make the opposite force of the hitbox same with the player, then make it run without screen refresh. You can do this by making a custom block for it:make sure that the custom block is running without screen refresh:
(this is assuming it's supposed to not go through the block)
thenYou can get more complicated than this, but this is how I mainly do it
- mstone326
-
1000+ posts
How to make a working hitbox?
Can you share the project. The same will hold true though with the hitbox, when it detects collision undo the move you just made. Is the hitbox a separate sprite or is it a costume of your main sprite?
- DerpyHead0
-
1000+ posts
How to make a working hitbox?
undoing the move can lead to problems, because you stop moving right before you hit the ground, and then have to fall down again to actually touch it. try changing the position until right when the player leaves the ground, so it can't go past that. (make sure you put it in a custom block with “run without screen refresh” enabled)
For a scrolling game, this doesn't work directly with camera x and y for a scrolling platformer, because the level won't actually move until the loop is done, which will then never happen. They're basically waiting for each other to do something. You need to move the position of the player AND change camera position at the same time, then move the player back to the right position without changing camera position.
you can find an example of this in this platformer i made here: https://scratch.mit.edu/projects/207439584/#editor
it also has some more things added in too.
I hope this isn't too confusing, happy to help anytime!
For a scrolling game, this doesn't work directly with camera x and y for a scrolling platformer, because the level won't actually move until the loop is done, which will then never happen. They're basically waiting for each other to do something. You need to move the position of the player AND change camera position at the same time, then move the player back to the right position without changing camera position.
you can find an example of this in this platformer i made here: https://scratch.mit.edu/projects/207439584/#editor
it also has some more things added in too.
I hope this isn't too confusing, happy to help anytime!

- Discussion Forums
- » Help with Scripts
-
» How to make a working hitbox?