Is there any better way to implement hitbox/hurtbox system in godot platformer?

31 views Asked by At

let say I want to create an enemy that deal damage to player when touch and can receive damage from player (like Hollow Knight).

Here my current solution

  1. Create hitbox at the player's weapon.
  2. Create hurtbox at enemy's body
  3. Create hitbox at enemy's body
  4. Create hurtbox at player's body

If I use this method, every enemy will have to check 3 collision (2 Area2D and itself Character2D). Which I think it too much (I concerned about performance), enemy hitbox and hurtbox are usually the same shape anyway.

I have an idea to merge them, but isn't that anti-pattern? And I plan to have enemies that hitbox isn't the same shape as hurtbox.

Is there any better solution? I'm quite new to godot.

0

There are 0 answers