Following a tutorial that I found by Bitlytic where he used instanced scenes to manage damage, hit detection, and health; I decided to use a similar system (and by similar I mean I copied the bits I like and changed the ones I didn't). Problem is, while the player script tells the weapon script that it needs to execute, the hit is not detected by the hitbox. I know I can use signals in the level to accomplish this but I am loathed to do it this way because of the headache it'd cause me in future. Is there a way?
weapon code
`#sets 3 hitboxes in the attack area to hit
func _get_overlapping_bodies(areas):
targets = areas
if areas.size <= 0:
enemy_in_range = false
if areas.size >= 1:
enemy_in_range = true
target_1 = targets[0]
target_2 = targets[1]
target_3 = targets[2]
#attack handler
func weapon_attack():
print("weapon: attacking")
if enemy_in_range:
var attack = Attack.new()
attack.attack_damage = weapon_attack_damage
attack.knockback_force = weapon_knockback_force
attack.attack_position = get_parent().global_position
target_1.damage(attack)
if target_2:
target_2.damage(attack)
if target_3:
target_3.damage(attack)
print("weapon use")
`