forked from xiangwang25/whale-town-front-v2
feat: add nearby social interactions
This commit is contained in:
14
_Core/utils/InteractionAnchor.gd
Normal file
14
_Core/utils/InteractionAnchor.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
Reference in New Issue
Block a user