How to get area enter using a for statement?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Newby

I know there is a signal but I’m using an extends script for my entities so i can signal the main script. That’s why i want to know if there is a way to detect area_entered cause get_colliding_areas detect every game tick and my attacks hit multiple times in one hit.

:bust_in_silhouette: Reply From: avencherus

Probably need to clarify your problem better. I imagine you’re looking for methods such as:

get_overlapping_areas()
get_overlapping_bodies()

You should only need the results once per frame, for repeated actions just loop over each body as many times as desired.

for hit_body in area.get_overlapping_bodies():
	
	for i in repeat_count:
		do_stuff_to(hit_body)

here is my dmg function

func dmg():
for area in $hitbox.get_overlapping_areas():
	var body=area.get_parent()
	if body.get("TYPE")!=TYPE:
		HP-=body.get("DMG")
		dmg_timer=10
		print(HP)

Newby | 2019-06-19 05:44