Best node hierarchy for a multi-hit-box 2D fighting game character?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godotwaiter
:warning: Old Version Published before Godot 3 was released.

Hi,

I’d like to create a character with multiple, tight hit-boxes (composed of 2D rect colliders) like the ones from games like Skullgirls. One of the reasons I moved on from Unity to Godot is how easy it is to animate and keyframe any variable or object, including the hit-boxes, along with the sprite during an animation. I’m wondering, however, what would be the best way to structure the node hierarchy for such a character. As the hit-boxes are tightly bound to the sprite’s shape in each animation frame, I would have to flip them along with the sprite when changing direction. I figure I can do this by making the colliders children of a KinematicBody2D which is itself a child of a sprite, and then apply set_scale(Vector2(-1,1)) on the Sprite to flip all children including the colliders.

From what I understand, collision checking is done on the KinematicBody2D object using is_colliding() and checks each collider under the KinematicBody2D. So I think this would mean that a collision with any hit-box under this KinematicBody2D would be treated the same. Therefore, if I want a hurt-box (for say an attack animation) I might have to use a separate KinematicBody2D for that. So here is my first proposal for such a fighter character:

Sprite

  • Animation Player
  • KinematicBody2D
    • Ground Collider
  • KinematicBody2D
    • Hit-box Colliders
  • KinematicBody2D
    • Hurt-box Colliders

Does this make sense? Many thanks.

EDIT: Tried a few things. Having a sprite as the top parent node allowed for easy flipping of the children but using move() of any of the KinematicBody2D children would not move the sprite as well (this makes sense). It looks like the best way to do it might instead to make a KinematicBody2D responsible for the Ground Collider to be the top parent. Then, make Sprite a child of that KinematicBody2D and then create an Area2D for each hit-box type and attach each to the sprite for easy flipping.

So:

KinematicBody2D

  • Animation Player
  • Sprite
    • Area2D
      • Hit-box Colliders
    • Area2D
      • Hurt-box Colliders
  • Ground Collider