Turning off Hitboxes on first Hurtbox collision? #93
-
Hey all, hopefully a very silly oversight on my part. Working on applying damage on a hitbox colliding with an enemy's hurtbox, and I've noticed that my hitboxes are applying damage multiple times per hitbox itself. For example, the below image contains the animation player with the animation of an attack. During the time in the red rectangle, the same hitbox is dealing damage twice. I've tried making it so that at the end of the below code snippet, it would turn the attack hitbox off, but using set_deferred doesn't seem to work as I'd like. Any thoughts on how I could overcome this? func _on_fray_hitbox_3d_hitbox_entered(hitbox: FrayHitbox3D) -> void:
if(hitbox.attribute is AttackAttribute):
var battler_hit = BattlerHit.new(hitbox.attribute.damage, hitbox.attribute.battler_stats, hitbox.attribute.hit_chance, hitbox.attribute.damage_scaling, hitbox.attribute.damage_type)
if battler_hit.is_successful():
self.current_hits.append(battler_hit)
self.take_hit(battler_hit)
velocity.x -= hitbox.attribute.knockback_force
velocity.y += hitbox.attribute.knockup_force
hitstun_timer.start(hitbox.attribute.hitstun)
hitbox.set_deferred("monitorable", false) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Applying damage should probably occur at the attack level instead of the hitbox level, such as hitboxes firing a signal hooked by a shared monitor object. Then, state about the attack ("has it done damage yet?") can be handled there, irrespective of what the hitboxes are doing. |
Beta Was this translation helpful? Give feedback.
Applying damage should probably occur at the attack level instead of the hitbox level, such as hitboxes firing a signal hooked by a shared monitor object. Then, state about the attack ("has it done damage yet?") can be handled there, irrespective of what the hitboxes are doing.