Fix player falling through terrain

Player gets its own CapsuleShape3D (was a small CylinderShape3D, never
actually shared with anything — the shared oversized capsule flagged
earlier only affects the 4 mountain props, unrelated to the player).

Real cause of the fall-through: the crown collision is a zero-thickness
trimesh and the player spawned with exactly zero clearance sitting
right on the surface, a classic tunneling setup. Fixed by giving the
trimesh backface_collision (collide from both sides) and spawning the
player with a bit of headroom so it settles onto the floor instead of
starting embedded in it. Verified headless: player now falls from
spawn height to rest exactly on the surface and stays on_floor=true
over a 3s simulated run.
This commit is contained in:
Jonas Reith 2026-08-26 19:58:28 +02:00
parent 817c701bd1
commit 4b21780f6d
2 changed files with 7 additions and 5 deletions

View File

@ -13,9 +13,9 @@
ambient_light_color = Color(0, 0, 0.31764707, 1) ambient_light_color = Color(0, 0, 0.31764707, 1)
ambient_light_energy = 0.3 ambient_light_energy = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_7mycd"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_player"]
height = 0.5
radius = 0.16 radius = 0.16
height = 0.5
[sub_resource type="AtlasTexture" id="AtlasTexture_lquwl"] [sub_resource type="AtlasTexture" id="AtlasTexture_lquwl"]
atlas = ExtResource("2_h2yge") atlas = ExtResource("2_h2yge")
@ -177,11 +177,11 @@ environment = SubResource("Environment_h2yge")
script = ExtResource("1_terrain") script = ExtResource("1_terrain")
[node name="Player" type="CharacterBody3D" parent="." unique_id=1504574304 groups=["player"]] [node name="Player" type="CharacterBody3D" parent="." unique_id=1504574304 groups=["player"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
script = ExtResource("1_0xm2m") script = ExtResource("1_0xm2m")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player" unique_id=1483851051] [node name="CollisionShape3D" type="CollisionShape3D" parent="Player" unique_id=1483851051]
shape = SubResource("CylinderShape3D_7mycd") shape = SubResource("CapsuleShape3D_player")
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="Player" unique_id=155581900] [node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="Player" unique_id=155581900]
billboard = 2 billboard = 2

View File

@ -84,7 +84,9 @@ func _build_crown() -> void:
mi.mesh = mesh mi.mesh = mesh
body.add_child(mi) body.add_child(mi)
var cs := CollisionShape3D.new() var cs := CollisionShape3D.new()
cs.shape = mesh.create_trimesh_shape() var trimesh := mesh.create_trimesh_shape()
trimesh.backface_collision = true # dünnes Mesh: von beiden Seiten kollidieren, kein Durchfallen
cs.shape = trimesh
body.add_child(cs) body.add_child(cs)
add_child(body) add_child(body)