Discuss Scratch

Lion9120
Scratcher
4 posts

How do I make working hitboxes

Whenever I want to make some game. Maybe some maze or something. I can never find out how to make hitboxes. I really want to know how to so I can make more projects without having trouble
deck26
Scratcher
1000+ posts

How do I make working hitboxes

A hitbox is useful because different costumes may not detect a hit and, for example, you may move and detect nothing but then change costume and be touching the wall. Within a frame you can change costume several times but the user will only see the last one selected when the frame is actually drawn. So if you have a forever loop for example, you might select the hitbox costume and make any intended moves and check the validity of the move. You can then undo any invalid move and switch to the appropriate player costume before the end of the loop.

Does that help?
Lion9120
Scratcher
4 posts

How do I make working hitboxes

I'll try it out later
Lion9120
Scratcher
4 posts

How do I make working hitboxes

when green flag clicked
forever
if <touching [ v] ?> then
change y by (-5)

end
end

is this the script?
deck26
Scratcher
1000+ posts

How do I make working hitboxes

Lion9120 wrote:

when green flag clicked
forever
if <touching [ v] ?> then
change y by (-5)

end
end

is this the script?
Only if your sprite is constantly moving +5 in the y direction in another script and even then you don't know which script is running last within the frame. The more normal approach is to make a move in whatever direction, check for touching and undo the move if the sprite is touching the wall (or whatever). So you may move right in response to the right arrow key which would be changing x by a constant value but if you then find the sprite is touching you'd change x by subtracting the same value.
ewils287
Scratcher
10 posts

How do I make working hitboxes

Lion9120 wrote:

when green flag clicked
forever
if <touching [ v] ?> then
change y by (-5)

end
end

is this the script?

Generally, the script would look something like this:

Lion9120 wrote:

Whenever I want to make some game. Maybe some maze or something. I can never find out how to make hitboxes. I really want to know how to so I can make more projects without having trouble

You would use the following script:

when green flag clicked
forever
if <key (w v) pressed?> then
change y by (5)
if <touching (maze v)> then
change y by (-5)

and duplicate that script for a, s, and d (or whatever keys you are using for movement).

(Keep in mind that this script will be in the ‘Hitbox’ sprite: the displayed player will just always go to the position of the hitbox.)
carotte_
Scratcher
5 posts

How do I make working hitboxes

u also have to change to the hitbox costume before detecting collisions
Lion9120
Scratcher
4 posts

How do I make working hitboxes

carotte_ wrote:

u also have to change to the hitbox costume before detecting collisions
what do you mean by changing the hitbox costume
Link2358
Scratcher
100+ posts

How do I make working hitboxes

Lion9120 wrote:

what do you mean by changing the hitbox costume
They said change to the hitbox costume

carotte_ wrote:

u also have to change to the hitbox costume before detecting collisions

Powered by DjangoBB