diff --git a/world/poi/poi.gd b/world/poi/poi.gd index 274131a..2184001 100755 --- a/world/poi/poi.gd +++ b/world/poi/poi.gd @@ -16,6 +16,23 @@ func _ready() -> void: _update_visuals() body_entered.connect(_on_body_entered) body_exited.connect(_on_body_exited) + # Terrain-Kollision braucht mind. einen Physik-Tick um registriert zu sein + await get_tree().physics_frame + _snap_to_terrain() + +# Handplatzierte Y-Werte treffen die geneigten Facetten nicht exakt (die Höhe +# ist keine reine Funktion des Radius, siehe terrain.gd). Statt jede Position +# neu von Hand zu berechnen: per Raycast auf die echte Terrain-Oberfläche +# schnappen, damit Sprite/Hitbox garantiert am Boden sitzen. +func _snap_to_terrain() -> void: + var space_state := get_world_3d().direct_space_state + var from := global_position + Vector3(0, 20, 0) + var to := global_position + Vector3(0, -20, 0) + var query := PhysicsRayQueryParameters3D.create(from, to) + query.exclude = [get_rid(), $StaticBody3D.get_rid()] + var result := space_state.intersect_ray(query) + if result: + global_position.y = result.position.y + 0.5 func _update_visuals() -> void: if visited: diff --git a/world/poi/poi.tscn b/world/poi/poi.tscn index fed6ee5..23e9193 100755 --- a/world/poi/poi.tscn +++ b/world/poi/poi.tscn @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://c3ajv7vb8c4fb" path="res://assets/debug/checkerboard.png" id="2_yof6k"] [sub_resource type="SphereShape3D" id="SphereShape3D_gwpk6"] -radius = 1.3 +radius = 0.6 [sub_resource type="SpriteFrames" id="SpriteFrames_0surh"] animations = [{ @@ -18,8 +18,8 @@ animations = [{ }] [sub_resource type="CylinderShape3D" id="CylinderShape3D_58c6p"] -radius = 1.0 -height = 2.4 +radius = 0.4 +height = 1.0 [node name="POI" type="Area3D" unique_id=1770000468] script = ExtResource("1_gwpk6") @@ -29,6 +29,7 @@ shape = SubResource("SphereShape3D_gwpk6") [node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="." unique_id=1205831120] billboard = 2 +pixel_size = 0.004 sprite_frames = SubResource("SpriteFrames_0surh") [node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1488376384] @@ -40,12 +41,13 @@ shape = SubResource("CylinderShape3D_58c6p") transform = Transform3D(6, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0) [node name="NameLabel" type="Label3D" parent="Billboard" unique_id=1419647885] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.018201571, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.13, 0) billboard = 1 text = "???" font_size = 16 [node name="InteractionPrompt" type="Label3D" parent="Billboard" unique_id=2059219662] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.09, 0) visible = false billboard = 1 font_size = 12 diff --git a/world/poi/poi_gate.gd b/world/poi/poi_gate.gd index f9c1d9e..f03eeb4 100644 --- a/world/poi/poi_gate.gd +++ b/world/poi/poi_gate.gd @@ -18,6 +18,21 @@ func _ready() -> void: _update_visuals() body_entered.connect(_on_body_entered) body_exited.connect(_on_body_exited) + # Terrain-Kollision braucht mind. einen Physik-Tick um registriert zu sein + await get_tree().physics_frame + _snap_to_terrain() + +# Siehe poi.gd: handplatzierte Y-Werte treffen die geneigten Facetten nicht +# exakt, per Raycast auf die echte Terrain-Oberfläche schnappen. +func _snap_to_terrain() -> void: + var space_state := get_world_3d().direct_space_state + var from := global_position + Vector3(0, 20, 0) + var to := global_position + Vector3(0, -20, 0) + var query := PhysicsRayQueryParameters3D.create(from, to) + query.exclude = [get_rid(), $StaticBody3D.get_rid()] + var result := space_state.intersect_ray(query) + if result: + global_position.y = result.position.y + 0.3 func _all_required_visited() -> bool: var pois := get_tree().get_nodes_in_group(required_group) diff --git a/world/poi/poi_gate.tscn b/world/poi/poi_gate.tscn index 8637ebe..fc87702 100644 --- a/world/poi/poi_gate.tscn +++ b/world/poi/poi_gate.tscn @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://c3ajv7vb8c4fb" path="res://assets/debug/checkerboard.png" id="2_gate"] [sub_resource type="SphereShape3D" id="SphereShape3D_gate"] -radius = 1.3 +radius = 0.6 [sub_resource type="SpriteFrames" id="SpriteFrames_gate"] animations = [{ @@ -18,8 +18,8 @@ animations = [{ }] [sub_resource type="CylinderShape3D" id="CylinderShape3D_gate"] -radius = 1.0 -height = 2.4 +radius = 0.4 +height = 1.0 [node name="POIGate" type="Area3D"] script = ExtResource("1_gate") @@ -29,6 +29,7 @@ shape = SubResource("SphereShape3D_gate") [node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."] billboard = 2 +pixel_size = 0.004 sprite_frames = SubResource("SpriteFrames_gate") [node name="StaticBody3D" type="StaticBody3D" parent="."] @@ -37,7 +38,7 @@ sprite_frames = SubResource("SpriteFrames_gate") shape = SubResource("CylinderShape3D_gate") [node name="Billboard" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) [node name="NameLabel" type="Label3D" parent="Billboard"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)