> - If I’ve got an attack that puts out multiple hitboxes, I’d probably need something that would prevent an enemy getting hit multiple times if it’s meant to be a single-hit attack. I have no clue how I would go about this. Do you have any ideas?
I didn't think about this much, but here's what I would try.
You could use a simple flag on the receiving object, isHit, true or false. When you check overlap with hitbox, this must be false, and it would be set to true so that following hit events no longer run until you set isHit to false again. Could be until the end of a tick, could be longer. Also can be used for invincibility frames, although I think the traditional way to do that would just be to remove the hurtbox entirely. Edit: Pick nth instance is probably the way to go.
For the overlap check, you could also add a pick Nth instance (first). If there is just one overlapping, no problem. If there are multiple, it would only run on the first one. You'd have to work out some sort of priority system if there are hits of different types/damages that could trigger together.
Otherwise just sticking with single hitboxes is perfectly valid too.
I haven't tried this and there are probably kinks to work out, but I'm sure it can be done.
> - Say if player one and player two swing a ground attack at slightly different times. Player 1’s attack ends first and the function that called for the Hitbox to be created calls for the Hitbox to be destroyed. Would this not prematurely destroy Player 2’s Hitbox? I’m also not sure how I could prevent this. Do you have any ideas?
You would associate each hitbox with it's owner sprite. Most straightforward way is by instance variable. Upon creating a hitbox for a player, set the hitbox instance variable "source" to player.uid. You can then pick by this "source" instance variable, if you only wanted to remove boxes for a certain player.
I think you can do something with hierarchies as well? I haven't explored that at all.
> - When you say the hitboxes don’t have to be perfect rectangles, are you saying I can make an irregularly shaped area by overlapping multiple rectangles, or are you saying there’s some way to turn an instance of the universal hitbox sprite into a circle or oval during runtime?
I was thinking irregularly shaped area with overlapping rectangles. But that was just an idea since you seemed interested in more accurate hitboxes.
There's also nothing keeping you from having both a circle/oval hitbox along with your rectangle hitbox, besides a little more complexity. You could also make it the same way with a function and resize as needed. Those two basic shapes should get you quite far with possible shapes with minimal effort, especially compared with having to make a unique collision bounds for every frame of every animation you plan to have in the game.
You can put the two shape hitbox objects either as different animation frames of the same object (which means you add one more parameter to your function to pick which kind to make/animation frame to set), or you can use two separate objects and put them in a family to treat them the same.
Thanks for all the help! I think I got the ground attack and enemy damage/death to be fully functional. I used the same logic that I used to make enemies receive damage to redo and streamline the logic I used to make the player receive damage from different enemy types: youtu.be/q1FWmKGSKTU
In the process of streamlining, I turned the Platform behavior for enemies into a family behavior, and added and tested some instance variables I plan to use in the future, namely YKnockback and TakeKnockback (boolean that determines whether the enemy takes knockback to begin with). These weren't made at the time of recording the short video.
As for how to separate Hitboxes based on which player they belong to, I could definitely do that. Another thing I was considering was just making "Red Hitbox", "Blue Hitbox", etc. which might make it easier for me from a purely visual looking-at-my-own-code perspective, but I'll see when I get there.
And as for making moves with multiple, possibly overlapping Hitboxes, I think I understand how to use nth instance, but if I don't it'll be something I can look at separately later down the line, especially because I'm not sure if I'll end up using it.
Again, thank you so much for your help!