Hello!
I want to create multiple selection like in AoE (age of empires), but area2d work with delay.
Used code:
func select(zone:Rect2):
var shape = RectangleShape2D.new()
shape.extents = Vector2(abs(zone.size.x-zone.position.x), abs(zone.size.y-zone.position.y))/2
$Area2D/CollisionShape2D.shape = shape
selection_zone.position = zone.position + Vector2(zone.size.x-zone.position.x, zone.size.y-zone.position.y)/2 + Vector2(1,2)
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
print($Area2D.get_overlapping_bodies())
#place to process overlaping bodies data
$Area2D/CollisionShape2D.shape = null
If i remove one of these two yields code doesnt work properly and even if area is overlaping bodies, it prints out empty array.
This code works fine, but it feels like im doing something wrong. Can someone explaim me please why it takes two idle frames for area2d to "apply" shape changes?