Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Hitbox wont line up
- Him_is_bob
-
Scratcher
75 posts
Hitbox wont line up
I am making a game as a tribute to the popular game wave wave which itself is based off of the geometry dash wave. I have made a separate hitbox sprite to match geometry dash more. though if you turn on show hitboxes you can see it is not lines up. there is a separate costume in the player sprite showing where the hitbox should be.https://scratch.mit.edu/projects/949096491/editor
- benche1
-
Scratcher
100+ posts
Hitbox wont line up
Just transfer the death code to the original sprite and get rid of the hitbox.
- Him_is_bob
-
Scratcher
75 posts
Hitbox wont line up
Just transfer the death code to the original sprite and get rid of the hitbox.i would but i want the size oof the hitbox i made
- benche1
-
Scratcher
100+ posts
Hitbox wont line up
Actually, you could just have the hitbox have the same code for movement as the original sprite
Last edited by benche1 (Jan. 12, 2024 20:24:53)
- Him_is_bob
-
Scratcher
75 posts
Hitbox wont line up
Actually, you could just have the hitbox have the same code for movement as the original spriteyes but my problem is I want that size hitbox and I have no idea where to even start on how to do it without a costume
- PhiPhenomenon
-
Scratcher
500+ posts
Hitbox wont line up
The hitbox won't line up with your sprite because the hitbox has a frame of lag behind your sprite. This is basically what happens:

So the way to fix this would be to move the sprite and then the hitbox so that the hitbox in on top of the sprite. Unfortunately, Scratch will run the sprite code first, so this might not be possible with clones.
However, it's quite possible to do it without clones. You can switch between costumes instead. Since every costume of a sprite shares the same coordinates, it gets rid of the lag issue. You can implement this logic into your game:
Switching the costume back to the display sprite will make sure that the player cannot see the hitbox, but can see the intended costume.

So the way to fix this would be to move the sprite and then the hitbox so that the hitbox in on top of the sprite. Unfortunately, Scratch will run the sprite code first, so this might not be possible with clones.
However, it's quite possible to do it without clones. You can switch between costumes instead. Since every costume of a sprite shares the same coordinates, it gets rid of the lag issue. You can implement this logic into your game:
when green flag clicked
forever
switch costume to [hitbox v]
Movement :: grey
if <touching [wall v] ?> then
Game over :: grey
end
switch costume to [display v]
end
Switching the costume back to the display sprite will make sure that the player cannot see the hitbox, but can see the intended costume.
- deck26
-
Scratcher
1000+ posts
Hitbox wont line up
Perfectly possible to still do this with a clone - just broadcast to move the clone afrter the sprite has moved. Use an if block to ensure it is the hitbox that runs the script.
- Discussion Forums
- » Help with Scripts
-
» Hitbox wont line up