Discuss Scratch

dogefan91
Scratcher
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
Scratcher
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:
definehitbox
make sure that the custom block is running without screen refresh:
(this is assuming it's supposed to not go through the block)
then
foreveriftouchinghitbox?thenchangeybyspeedoftheplayer
You can get more complicated than this, but this is how I mainly do it
dogefan91
Scratcher
14 posts

How to make a working hitbox?

G157 wrote:

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:
definehitbox
make sure that the custom block is running without screen refresh:
(this is assuming it's supposed to not go through the block)
then
foreveriftouchinghitbox?thenchangeybyspeedoftheplayer
You can get more complicated than this, but this is how I mainly do it
Sure, Thanks for the info, im making a SCROLLING PLATFORMER, not a screen by screen platformer.
mstone326
Scratcher
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
Scratcher
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!

Powered by DjangoBB