diff --git a/level.gd b/level.gd index 8c2277a..5ba5a09 100644 --- a/level.gd +++ b/level.gd @@ -1,7 +1,7 @@ extends Node3D -@export var dimension: int = 15 -@export var path_count: int = 7 +@export var dimension: int = 5 +@export var path_count: int = 5 func dir_to_vector(dir: int) -> Vector2i: assert(dir >= 0 and dir <= 3) @@ -33,6 +33,9 @@ func _ready() -> void: $Player.position.x = station.x * 100 $Player.position.z = station.y * 100 + $Pedestrian.position.x = station.x * 100 + $Pedestrian.position.z = station.y * 100 + var paths: Array = [] for path_idx in range(path_count): var path: Array[Vector2i] = [ diff --git a/level.tscn b/level.tscn index 977ca0c..5863bff 100644 --- a/level.tscn +++ b/level.tscn @@ -4,6 +4,7 @@ [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="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"] ambient_light_source = 2 @@ -22,7 +23,7 @@ script = ExtResource("1_0b4ue") environment = SubResource("Environment_vonw3") [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")] 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) 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] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.874296, 3.5, -11.78) mesh = SubResource("BoxMesh_oi3di") [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 fov = 55.0 script = ExtResource("2_vonw3") diff --git a/pedestrian.gd b/pedestrian.gd new file mode 100644 index 0000000..03bc00f --- /dev/null +++ b/pedestrian.gd @@ -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) diff --git a/pedestrian.gd.uid b/pedestrian.gd.uid new file mode 100644 index 0000000..27b0472 --- /dev/null +++ b/pedestrian.gd.uid @@ -0,0 +1 @@ +uid://beqs2m2yf1igp diff --git a/pedestrian.tscn b/pedestrian.tscn new file mode 100644 index 0000000..172e96d --- /dev/null +++ b/pedestrian.tscn @@ -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] diff --git a/player.gd b/player.gd index a41df9a..2d5cde4 100644 --- a/player.gd +++ b/player.gd @@ -1,6 +1,6 @@ extends CharacterBody3D const BASE_STAMINA = 50 -const BASE_SPEED = 100 +const BASE_SPEED = 50 const SPRINT_MULT = 1.6 const STAMINA_COST = 15 const STAMINA_RECOVER = 10