Both poi.tscn and poi_gate.tscn had two problems stacking on top of each other: the solid StaticBody3D collider was a fixed-orientation BoxShape3D (with a Z-offset originally tuned for the old non-billboard ruins sprite), and the Area3D's own proximity-detection sphere also carried that same leftover Z-offset. Neither rotates with the sprite, which now billboards to face the camera (billboard=2) — so depending on viewing angle you'd either bump into invisible air or walk clean through the visible sprite, and the interact prompt appeared at wildly different distances depending on approach direction. Fix: replaced the oriented box with a centered CylinderShape3D (radius 1.0) for the solid collider — rotationally symmetric around Y, so it matches a billboarded sprite from any camera angle by construction, no per-frame reorientation needed. Removed the Z-offset from the Area3D's detection sphere and grew its radius to 1.3 (>= the solid cylinder's radius), so interaction becomes available at or before physical contact, not after pushing further in. Verified headless: drove the player at a POI from 4 different approach angles (0/90/180/270°) and measured both the distance where movement gets blocked and the distance where player_nearby flips true. Blocking distance is now consistent (~1.16-1.17 units) across all four angles instead of varying with direction, and in every case interaction was ready at or before the blocking distance.
49 lines
1.3 KiB
GDScript
Executable File
49 lines
1.3 KiB
GDScript
Executable File
extends Area3D
|
|
|
|
@export var poi_name: String = "Ruinen"
|
|
@export var marker_color: Color = Color.WHITE
|
|
|
|
@onready var sprite: AnimatedSprite3D = $AnimatedSprite3D
|
|
@onready var name_label: Label3D = $Billboard/NameLabel
|
|
@onready var prompt: Label3D = $Billboard/InteractionPrompt
|
|
|
|
var player_nearby: bool = false
|
|
var visited: bool = false
|
|
|
|
func _ready() -> void:
|
|
prompt.visible = false
|
|
prompt.text = "[F] Interact"
|
|
_update_visuals()
|
|
body_entered.connect(_on_body_entered)
|
|
body_exited.connect(_on_body_exited)
|
|
|
|
func _update_visuals() -> void:
|
|
if visited:
|
|
name_label.text = poi_name
|
|
sprite.modulate = marker_color
|
|
name_label.modulate = Color(1.0, 1.0, 1.0, 1.0)
|
|
else:
|
|
name_label.text = "???"
|
|
# Ausgegraut, behält aber die Kennfarbe
|
|
sprite.modulate = marker_color * Color(0.1, 0.1, 0.1, 1.0)
|
|
name_label.modulate = Color(0.6, 0.6, 0.6, 1.0)
|
|
|
|
func _on_body_entered(body: Node3D) -> void:
|
|
if body.is_in_group("player"):
|
|
player_nearby = true
|
|
prompt.text = "[F] Interact"
|
|
prompt.visible = true
|
|
|
|
func _on_body_exited(body: Node3D) -> void:
|
|
if body.is_in_group("player"):
|
|
player_nearby = false
|
|
prompt.visible = false
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if player_nearby and Input.is_action_just_pressed("interact"):
|
|
# Beim ersten Besuch entdecken
|
|
if not visited:
|
|
visited = true
|
|
_update_visuals()
|
|
InteractionManager.open_poi(self)
|