Discuss Scratch

me_is_big_brain
Scratcher
16 posts

hit detection acting really wonky

im trying to make a fighting game engine, but i'm facing an issue with the hitboxes

normally, hitting an opponent will immediately apply any effects the attack may have, which works fine. however, as long as the opponent is stunned, certain attacks WILL hit them; along with waiting until they're actually allowed to be damaged

i have zero idea why this is happening! i've attempted a few fixes, but none of them worked, so i'm resorting to the forums of shame. if you can help, please do!



to replicate:
attack the opponent with the first ability to get them laying down. then, use the third ability before they can get up
(alternatively, push them away and then use a move quickly enough)


https://scratch.mit.edu/projects/988927025/

Last edited by me_is_big_brain (March 26, 2024 15:06:53)


love is in the air? WRONG! Memory Leak
Cool_Dude2022
Scratcher
100+ posts

hit detection acting really wonky

me_is_big_brain wrote:

im trying to make a fighting game engine, but i'm facing an issue with the hitboxes

normally, hitting an opponent will immediately apply any effects the attack may have, which works fine. however, if the opponent is laying down, attacks that shouldn't reach them will wait until they get up, and THEN they'll be attacked, despite the hitbox being long gone.

i have zero idea why this is happening! i've attempted a few fixes, but none of them worked, so i'm resorting to the forums of shame. if you can help, please do!



to replicate:
attack the opponent with the first ability to get them laying down. then, use the third ability before they can get up.




https://scratch.mit.edu/projects/988927025/

My idea would be to add a check, this would check if the opponent is “laying down” and then either hit/miss the attack.

when I receive [Opponent Lay Down v]
set [Opponent Status? v] to [Laying Down]

when I receive [Opponent Get Up v]
set [Opponent Status? v] to [Standing]

Then, you can use something like this in the attack script:

forever
wait until <key [space v] pressed?> // Just a random boolean to signal when the player attacks. Completely arbitrary.
wait until <not <key [space v] pressed?>>
if <(Opponent Status?) = [Laying Down]> then
Attack animation
Send out a projectile
Miss the opponent
else
Attack animation
Send out a projectile
Hit the opponent
end
end

Did I help you fix your problem? If so, please nominate my project to be featured!

If my code is used, credit is NOT required
me_is_big_brain
Scratcher
16 posts

hit detection acting really wonky

i had this idea, but i figure that this would be too similar to just hard-coding it to work, which goes against the idea of making the engine easy to remix. i'll try and see if it works well though, this might be better than i think!

love is in the air? WRONG! Memory Leak
me_is_big_brain
Scratcher
16 posts

hit detection acting really wonky

Cool_Dude2022 wrote:

me_is_big_brain wrote:

im trying to make a fighting game engine, but i'm facing an issue with the hitboxes

normally, hitting an opponent will immediately apply any effects the attack may have, which works fine. however, if the opponent is laying down, attacks that shouldn't reach them will wait until they get up, and THEN they'll be attacked, despite the hitbox being long gone.

i have zero idea why this is happening! i've attempted a few fixes, but none of them worked, so i'm resorting to the forums of shame. if you can help, please do!



to replicate:
attack the opponent with the first ability to get them laying down. then, use the third ability before they can get up.




https://scratch.mit.edu/projects/988927025/

My idea would be to add a check, this would check if the opponent is “laying down” and then either hit/miss the attack.

when I receive [Opponent Lay Down v]
set [Opponent Status? v] to [Laying Down]

when I receive [Opponent Get Up v]
set [Opponent Status? v] to [Standing]

Then, you can use something like this in the attack script:

forever
wait until <key [space v] pressed?> // Just a random boolean to signal when the player attacks. Completely arbitrary.
wait until <not <key [space v] pressed?>>
if <(Opponent Status?) = [Laying Down]> then
Attack animation
Send out a projectile
Miss the opponent
else
Attack animation
Send out a projectile
Hit the opponent
end
end
i did it… and it WAITED. the dummy literally waited until it was ALLOWED to be hurt?? i did learn some new info though. its PSYCHIC POWER, not even related to the hitbox at all, just if the move was used! however, it can be stopped if you use a different move

love is in the air? WRONG! Memory Leak
me_is_big_brain
Scratcher
16 posts

hit detection acting really wonky

the only issue was that i was using “IF” blocks as opposed to “IF/ELSE” blocks

love is in the air? WRONG! Memory Leak

Powered by DjangoBB