fix: make TestLevel load on 4.6.3; build geometry from GDScript
- test_level.tscn: minimal Node3D root (zero SubResource references) - debug/test_level_builder.gd: runtime floor/walls/lighting/camera/UI shapes/meshes created from BoxShape3D/BoxMesh — no .tscn subresources - project.godot: revert features to 4.6 (installed build is 4.6.3)
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
extends Node3D
|
||||
class_name TestLevelBuilder
|
||||
## Builds the test level ONLY from code — no .tscn SubResource references.
|
||||
## Attach to a Node3D and call build() from _ready().
|
||||
|
||||
func build() -> void:
|
||||
_build_floor()
|
||||
_build_walls()
|
||||
_build_lighting()
|
||||
_build_camera()
|
||||
_build_ui()
|
||||
|
||||
|
||||
func _box_static(pos: Vector3, size: Vector3, color: Color) -> StaticBody3D:
|
||||
var body := StaticBody3D.new()
|
||||
body.position = pos
|
||||
body.name = "Static_" + str(pos)
|
||||
add_child(body)
|
||||
var shape := CollisionShape3D.new()
|
||||
shape.shape = BoxShape3D.new()
|
||||
shape.shape.size = size
|
||||
body.add_child(shape)
|
||||
var mesh := MeshInstance3D.new()
|
||||
mesh.mesh = BoxMesh.new()
|
||||
mesh.mesh.size = size
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.albedo_color = color
|
||||
mesh.mesh.surface_set_material(0, mat)
|
||||
body.add_child(mesh)
|
||||
return body
|
||||
|
||||
|
||||
func _build_floor() -> void:
|
||||
_box_static(Vector3(0, -1.1, 0), Vector3(30, 0.4, 30), Color(0.35, 0.25, 0.15))
|
||||
|
||||
|
||||
func _build_walls() -> void:
|
||||
# Thin, tall walls for wallrun / walljump testing
|
||||
_box_static(Vector3(0, 3, -15), Vector3(30, 6, 0.4), Color(0.55, 0.45, 0.35))
|
||||
_box_static(Vector3(15, 3, 0), Vector3(0.4, 6, 30), Color(0.55, 0.45, 0.35))
|
||||
_box_static(Vector3(-15, 3, 0), Vector3(0.4, 6, 30), Color(0.55, 0.45, 0.35))
|
||||
|
||||
|
||||
func _build_lighting() -> void:
|
||||
var sun := DirectionalLight3D.new()
|
||||
sun.name = "Sun"
|
||||
sun.position = Vector3(0, 10, 0)
|
||||
sun.rotation_degrees = Vector3(50, 0, 0)
|
||||
sun.light_color = Color(1, 0.95, 0.85)
|
||||
sun.light_energy = 1.1
|
||||
sun.shadow_enabled = true
|
||||
add_child(sun)
|
||||
|
||||
|
||||
func _build_camera() -> void:
|
||||
var cam := Camera3D.new()
|
||||
cam.name = "FpsCamera"
|
||||
cam.current = true
|
||||
cam.position = Vector3(0, 1.7, 0)
|
||||
cam.fov = 90.0
|
||||
add_child(cam)
|
||||
# Spawn marker
|
||||
var spawn := Node3D.new()
|
||||
spawn.name = "PlayerSpawn"
|
||||
spawn.position = Vector3(0, 1.5, 8)
|
||||
add_child(spawn)
|
||||
|
||||
|
||||
func _build_ui() -> void:
|
||||
var canvas := CanvasLayer.new()
|
||||
canvas.name = "UI"
|
||||
add_child(canvas)
|
||||
var speed := Label.new()
|
||||
speed.name = "SpeedLabel"
|
||||
speed.offset_left = 16
|
||||
speed.offset_top = 16
|
||||
speed.offset_right = 520
|
||||
speed.offset_bottom = 48
|
||||
speed.text = "Speed: 0.0 m/s | State: --- | Chain: +0%"
|
||||
canvas.add_child(speed)
|
||||
var help := Label.new()
|
||||
help.name = "HelpLabel"
|
||||
help.offset_left = 16
|
||||
help.offset_top = 52
|
||||
help.offset_right = 720
|
||||
help.offset_bottom = 108
|
||||
help.text = (
|
||||
"WASD Move | Sprint=Shift | Slide=Ctrl+S | "
|
||||
"Double-Jump=Space twice | Dash=LShift | Wall-Jump=Jump at wall"
|
||||
)
|
||||
canvas.add_child(help)
|
||||
Reference in New Issue
Block a user