feat: add very stoopid pedestrian

This commit is contained in:
Dusk 2026-03-02 23:07:19 +01:00
parent 201868907a
commit 2f20c8a283
6 changed files with 55 additions and 5 deletions

View File

@ -1,7 +1,7 @@
extends Node3D extends Node3D
@export var dimension: int = 15 @export var dimension: int = 5
@export var path_count: int = 7 @export var path_count: int = 5
func dir_to_vector(dir: int) -> Vector2i: func dir_to_vector(dir: int) -> Vector2i:
assert(dir >= 0 and dir <= 3) assert(dir >= 0 and dir <= 3)
@ -33,6 +33,9 @@ func _ready() -> void:
$Player.position.x = station.x * 100 $Player.position.x = station.x * 100
$Player.position.z = station.y * 100 $Player.position.z = station.y * 100
$Pedestrian.position.x = station.x * 100
$Pedestrian.position.z = station.y * 100
var paths: Array = [] var paths: Array = []
for path_idx in range(path_count): for path_idx in range(path_count):
var path: Array[Vector2i] = [ var path: Array[Vector2i] = [

View File

@ -4,6 +4,7 @@
[ext_resource type="PackedScene" uid="uid://cmb3b7xrlboy3" path="res://player.tscn" id="1_u52ul"] [ext_resource type="PackedScene" uid="uid://cmb3b7xrlboy3" path="res://player.tscn" id="1_u52ul"]
[ext_resource type="Script" uid="uid://b5ebibi08tjvd" path="res://camera_3d.gd" id="2_vonw3"] [ext_resource type="Script" uid="uid://b5ebibi08tjvd" path="res://camera_3d.gd" id="2_vonw3"]
[ext_resource type="PackedScene" uid="uid://cqbu5r5pmnhc" path="res://chunk.tscn" id="3_f2txt"] [ext_resource type="PackedScene" uid="uid://cqbu5r5pmnhc" path="res://chunk.tscn" id="3_f2txt"]
[ext_resource type="PackedScene" uid="uid://c76lhqe6dqq50" path="res://pedestrian.tscn" id="4_f2txt"]
[sub_resource type="Environment" id="Environment_vonw3"] [sub_resource type="Environment" id="Environment_vonw3"]
ambient_light_source = 2 ambient_light_source = 2
@ -22,7 +23,7 @@ script = ExtResource("1_0b4ue")
environment = SubResource("Environment_vonw3") environment = SubResource("Environment_vonw3")
[node name="Player" parent="." unique_id=1536233267 instance=ExtResource("1_u52ul")] [node name="Player" parent="." unique_id=1536233267 instance=ExtResource("1_u52ul")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.286973, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0)
[node name="Chunk" parent="." unique_id=731620195 instance=ExtResource("3_f2txt")] [node name="Chunk" parent="." unique_id=731620195 instance=ExtResource("3_f2txt")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08452606, -3.8146973e-06, 0.120262146) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08452606, -3.8146973e-06, 0.120262146)
@ -31,12 +32,15 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08452606, -3.8146973e-06,
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.830486, 7.5, -23.788916) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.830486, 7.5, -23.788916)
mesh = SubResource("BoxMesh_vonw3") mesh = SubResource("BoxMesh_vonw3")
[node name="Pedestrian" parent="." unique_id=468620437 instance=ExtResource("4_f2txt")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.219554, 2.045658, 0)
[node name="MeshInstance3D3" type="MeshInstance3D" parent="." unique_id=373905113] [node name="MeshInstance3D3" type="MeshInstance3D" parent="." unique_id=373905113]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.874296, 3.5, -11.78) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.874296, 3.5, -11.78)
mesh = SubResource("BoxMesh_oi3di") mesh = SubResource("BoxMesh_oi3di")
[node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402] [node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 440.23715, 0) transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 113.43584, 0)
current = true current = true
fov = 55.0 fov = 55.0
script = ExtResource("2_vonw3") script = ExtResource("2_vonw3")

12
pedestrian.gd Normal file
View File

@ -0,0 +1,12 @@
extends StaticBody3D
@onready var x_movement = randi() % 10
@onready var z_movement = randi() % 10
func _process(delta: float) -> void:
if (randi() % 80) == 1:
x_movement = randi() % 10
z_movement = randi() % 10
randomize()
move_and_collide(Vector3(x_movement, 0, z_movement) * delta)

1
pedestrian.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://beqs2m2yf1igp

30
pedestrian.tscn Normal file
View File

@ -0,0 +1,30 @@
[gd_scene format=3 uid="uid://c76lhqe6dqq50"]
[ext_resource type="Script" uid="uid://beqs2m2yf1igp" path="res://pedestrian.gd" id="1_y5q06"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6pjml"]
height = 0.5
radius = 4.0
[sub_resource type="CylinderMesh" id="CylinderMesh_6pjml"]
top_radius = 1.0
bottom_radius = 1.0
height = 0.1
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_y5q06"]
albedo_color = Color(0.23, 0.23, 0.23, 1)
[node name="Pedestrian" type="StaticBody3D" unique_id=896871991]
collision_layer = 0
collision_mask = 0
script = ExtResource("1_y5q06")
[node name="Collision" type="CollisionShape3D" parent="." unique_id=1710819275]
shape = SubResource("CylinderShape3D_6pjml")
debug_color = Color(2.8878452e-07, 0.5747548, 0.82784265, 0.41960785)
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=58534625]
mesh = SubResource("CylinderMesh_6pjml")
surface_material_override/0 = SubResource("StandardMaterial3D_y5q06")
[node name="Area" type="Area3D" parent="." unique_id=332853531]

View File

@ -1,6 +1,6 @@
extends CharacterBody3D extends CharacterBody3D
const BASE_STAMINA = 50 const BASE_STAMINA = 50
const BASE_SPEED = 100 const BASE_SPEED = 50
const SPRINT_MULT = 1.6 const SPRINT_MULT = 1.6
const STAMINA_COST = 15 const STAMINA_COST = 15
const STAMINA_RECOVER = 10 const STAMINA_RECOVER = 10