Add experimental road generation (generated by deepseek)
This commit is contained in:
parent
7958bd288f
commit
5bf9ea473c
8 changed files with 97 additions and 1 deletions
18
scripts/road.gd
Normal file
18
scripts/road.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
extends Node3D
|
||||
|
||||
@export var despawn_distance := 50.0 # Distance behind player to despawn
|
||||
var player: Node3D
|
||||
|
||||
func _ready():
|
||||
# Find the player once when road spawns
|
||||
player = get_tree().get_first_node_in_group("player")
|
||||
|
||||
# Set up despawn area
|
||||
var area = $DespawnArea
|
||||
area.body_exited.connect(_on_body_exited)
|
||||
area.position.z -= 10 # Adjust for scaled position
|
||||
|
||||
func _on_body_exited(body: Node):
|
||||
if body == player:
|
||||
if global_position.x < player.global_position.x - despawn_distance:
|
||||
queue_free()
|
||||
Loading…
Add table
Add a link
Reference in a new issue