Files
whale-town-front-v2/_Core/utils/InteractionAnchor.gd
2026-07-21 23:07:31 +08:00

15 lines
666 B
GDScript

class_name InteractionAnchor
extends RefCounted
# 所有交互距离与地图标记共用的世界锚点。
# Area2D 优先使用实际 CollisionShape2D 的中心,避免脚本节点原点与碰撞区域有偏移时
# 出现“能交互的位置”和白圈不一致的问题。
static func get_position(node: Node2D) -> Vector2:
var area: Area2D = node as Area2D
if area != null:
for child: Node in area.get_children():
var collision_shape: CollisionShape2D = child as CollisionShape2D
if collision_shape != null and not collision_shape.disabled and collision_shape.shape != null:
return collision_shape.global_position
return node.global_position