|
Title: Beat em up / fighter - recognizing unique hits Post by: omgnoseat on September 02, 2012, 11:33:12 AM I'm currently working on a small smash brotherish fighting game side project, but have no experience with fighters or beat em ups.
I tried looking for articles, but they seem non existant. I'm having some trouble with the most basic feature, getting hit. The collisions are simply done by the sprite's bounding boxes for now, since it's still in an early phase. (http://desmond.imageshack.us/Himg689/scaled.php?server=689&filename=sampleju.jpg&res=landing) Scenario 1 Frame 1 entity is hit by player and is hit of backwards. Frame 2 The hit entity is still in the players boundingbox, and is hit again. We only want each attack to hit an entity once. Scenario 2 Frame 1 Entity hit by player. Frame 2 To try to solve the issue, we make the hit entity temporarily for a few frames. When another player tries to hit the entity in this frame, he is still invunerable from player 1's hit and does not receive the hit Scenario 3 To solve the issue from scenario 2, we give introduce a couple of new variables for the entities: AttackID: each attack has a unique ID HitID: the last known hit againt the entity itself is saved. Frame 1 The entity is hit by the player, everything is fine. entity.lastHit = player1.currentAttack.ID Frame 2 The entity is hit by both player 1 and player 2. the entity recognizes that it is hit the last frame by player 1, and does not apply player 1's hit. It does get hit by player 2. entity.lastHit = player2.currentAttack.ID Frame 3 the entity is hit by both player 1 and player 2. the entity recognizes that it is hit the last frame by player 2, and does not apply player 2's hit. however, it is now hit by player 1's same attack as frame 1 again. I could just make a list of HitID's, but I'm not sure if thats a nice solution. I feel like I'm overthinking this simple issue. Title: Re: Beat em up / fighter - recognizing unique hits Post by: Azure Lazuline on September 02, 2012, 12:04:03 PM I personally use a list of hit IDs. Each one is timed though, because the hit ID has to wrap around eventually (even if it's infeasible), so I usually set it to 1 second. One second after you're hit by an attack, you can get hit by it again. That also works out well for multi-hit moves, which can perhaps have a customizable hit invincibility time to allow for rapid-fire attacks without switching hit IDs every few frames.
Title: Re: Beat em up / fighter - recognizing unique hits Post by: Ludophonic on September 02, 2012, 12:30:49 PM I would reverse scenario 3.
Instead of having the players keep track of when they've been hit, have them them keep track of when they've hit someone else and not allow them to hit again for a tuneable period of time. Title: Re: Beat em up / fighter - recognizing unique hits Post by: omgnoseat on September 02, 2012, 12:35:37 PM I personally use a list of hit IDs. Each one is timed though, because the hit ID has to wrap around eventually (even if it's infeasible), so I usually set it to 1 second. One second after you're hit by an attack, you can get hit by it again. That also works out well for multi-hit moves, which can perhaps have a customizable hit invincibility time to allow for rapid-fire attacks without switching hit IDs every few frames. I actually was thinking about timing the ID's, setting the timer to the duration of the attack itself. But it might wise to make it a little big longer indeed, also prevents infinite juggles and comobos and stuff.I would reverse scenario 3. Never looked at it from the attacker's point of view, this sounds like a solid solution.Instead of having the players keep track of when they've been hit, have them them keep track of when they've hit someone else and not allow them to hit again for a tuneable period of time. Title: Re: Beat em up / fighter - recognizing unique hits Post by: Azure Lazuline on September 02, 2012, 12:54:05 PM Well, I meant giving each iteration of the attack a different ID, not just each type of attack, if that makes sense. When you hit the punch button and your character punches, it grabs the next available ID and assigns it to that specific attack. Next time you punch it's a different ID.
Title: Re: Beat em up / fighter - recognizing unique hits Post by: omgnoseat on September 02, 2012, 12:57:09 PM Well, I meant giving each iteration of the attack a different ID, not just each type of attack, if that makes sense. When you hit the punch button and your character punches, it grabs the next available ID and assigns it to that specific attack. Next time you punch it's a different ID. Yeah that's what I meant with unique ID :) |