Files

44 lines
1.4 KiB
GDScript
Raw Permalink Normal View History

2026-09-12 11:01:37 +02:00
extends SceneTree
var failures := 0
func _initialize() -> void: call_deferred("run")
func run() -> void:
var stage := Node3D.new()
root.add_child(stage)
StairFlight.build(stage, Vector3.ZERO, 1, 3.7, true, null)
for data in [[Vector3(0,-0.2,-2), Vector3(8,0.4,4)], [Vector3(0,3.5,9.4),Vector3(8,0.4,4)]]:
var body := StaticBody3D.new()
body.position = data[0]
var box := BoxShape3D.new()
box.size = data[1]
var shape := CollisionShape3D.new()
shape.shape = box
body.add_child(shape)
stage.add_child(body)
var p := CharacterBody3D.new()
p.floor_snap_length = 0.3
p.floor_max_angle = deg_to_rad(48)
var capsule := CapsuleShape3D.new()
capsule.height = 1.8
capsule.radius = 0.36
var collider := CollisionShape3D.new()
collider.shape = capsule
collider.position.y = 0.9
p.add_child(collider)
stage.add_child(p)
await physics_frame
await physics_frame
for lane in [-0.56,0.0,0.56]:
p.position = Vector3(lane,0.02,-1.5)
for tick in 160:
p.velocity = Vector3(signf(lane) * 1.0, -3, 5.8)
if lane == 0: p.velocity.x = 0
p.move_and_slide()
await physics_frame
var passed := p.position.z > 7.7 and p.position.y > 3.5
print("STAIR WALK lane=", lane, " position=", p.position, " passed=", passed)
if not passed: failures += 1
stage.queue_free()
await process_frame
print("STAIR WALK RESULT ", 3-failures, "/3")
quit(1 if failures else 0)