How to get a position of collision from area2d

Godot Version

<stable4.2>

Question

<Im trying to instantiate hit effect sprite at the position where collision occurred. by using area2d, how can I achieve this? I first tried by simply doing

var position = Vector2.ZERO
position = area.global_position
get_parent().add_child(hit_effect)
hit_effect.global_position = position

however, this caused hit effect always to be at center of object it collided. I would like to instantiate it at the position and rotate it based on the collision position. While I was googling, i found this article that explains how to get collision point by using area_shape_entered(area_rid: RID, area: Area2D, area_shape_index: int, local_shape_index: int). but I am not skilled enough to understand how to use that. anyway, i would appreciate if you could teach me how to get collision position from area2d. thanks.

2 Likes