Hi!
I’m trying to make a game similar to Vampire Survivors.
I’m having a problem with the damage-dealing/damage-taking architecture.
Right now, I have the basic HitBox and HurtBox components.
However, for example, enemies in the game will attack the player “with their bodies,” and if they’re inside the player’s HurtBox, they should deal damage to the player at regular intervals. Some weapons will work this way as well. But other weapons will only deal damage once, upon hitting the player.
My code currently doesn’t allow for continuous damage.
How can I fix this?
Do I need to create separate hitboxes for elements that deal periodic damage? And, for example, add a timer to them? But at the same time, there could be hundreds of enemies on the screen in a game like this, and adding a timer to each one doesn’t seem like the best idea.
What direction should I take?
class_name HitBox
extends Area2D
var damage: float = 10.0
func setup(damage: float) -> void:
self.damage = damage
class_name HurtBox
extends Area2D
signal hit_received(damage: float)
func _on_area_entered(hit_box: HitBox) -> void:
hit_received.emit(hit_box.damage)