im working on a attack action but when it works but in the opposite way if im up to a enamy it will dissapear with the player but if im away it will delete itself if someone can help that would be nice
@export var attacking = false
func attack():
var overlaping_object = $attack_area.get_overlapping_areas()
for area in overlaping_object:
var parent = area.get_parent()
parent.queue_free()
attacking = true
Hi!
attack_area.get_overlapping_areas()
will return every overlapping area, which means you may include areas so actually don’t want to attack.
Make sure attack_area
is not including something you don’t want to include (like the player’s collision area), or use physics layers to have more control on your attack detection.
how would i be able to do so???
I’d suggest you have a look at Physics introduction — Godot Engine (stable) documentation in English. You’re probably mostly interested in the Collision layers and masks part, but you obviously should read everything if you’re not used to physics in Godot.
1 Like
i appreciate it god bless