person added start position

This commit is contained in:
Nikolai Fesenko
2025-08-15 15:26:47 +02:00
parent b7bf4792f3
commit 7da59523a7
6 changed files with 56 additions and 7 deletions

View File

@@ -1,22 +1,31 @@
[gd_scene load_steps=4 format=3 uid="uid://dqrqq5vg8hek3"] [gd_scene load_steps=6 format=3 uid="uid://dqrqq5vg8hek3"]
[ext_resource type="ArrayMesh" uid="uid://dwd6ylq5xn6kj" path="res://Blends/Person/Person.obj" id="1_11yxf"] [ext_resource type="ArrayMesh" uid="uid://dwd6ylq5xn6kj" path="res://Blends/Person/Person.obj" id="1_11yxf"]
[ext_resource type="Script" uid="uid://d308e5vxshc06" path="res://Scripts/person.gd" id="1_dh77o"] [ext_resource type="Script" uid="uid://d308e5vxshc06" path="res://Scripts/person.gd" id="1_dh77o"]
[ext_resource type="Shader" uid="uid://bm15rdsdxldwl" path="res://Shaders/shirt.gdshader" id="3_dbviw"]
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_dh77o"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_kmh38"]
render_priority = 0
shader = ExtResource("3_dbviw")
shader_parameter/shirt_color = Vector3(0, 0, 0)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_dbviw"]
points = PackedVector3Array(0.465296, 4.41226, 2.90193, 0.333481, 5.90986, 1.44973, -0.46535, 4.41226, 2.90193, 0.465296, 2.1221, 2.90193, 0.88668, -1.00046, 1.81769, 0.465296, 4.41226, -1.76192, 0.333481, 5.90986, -0.25128, -0.333667, 5.90986, 1.44973, -0.46535, 4.41226, -1.76192, -0.46535, 2.1221, 2.90193, 0.88668, -1.35832, 1.81769, 0.88668, -1.00046, -0.616956, 0.465296, 2.1221, -1.76192, -0.333667, 5.90986, -0.25128, -0.46535, 2.1221, -1.76192, -0.46535, 1.86882, 1.75606, -0.424191, -1.35832, 1.81769, 0.88668, -1.35832, -0.616956, -0.424191, -1.35832, -0.616956, -0.46535, 1.86882, -0.6165) points = PackedVector3Array(0.465296, 4.41226, 2.90193, 0.333481, 5.90986, 1.44973, -0.46535, 4.41226, 2.90193, 0.465296, 2.1221, 2.90193, 0.88668, -1.00046, 1.81769, 0.465296, 4.41226, -1.76192, 0.333481, 5.90986, -0.25128, -0.333667, 5.90986, 1.44973, -0.46535, 4.41226, -1.76192, -0.46535, 2.1221, 2.90193, 0.88668, -1.35832, 1.81769, 0.88668, -1.00046, -0.616956, 0.465296, 2.1221, -1.76192, -0.333667, 5.90986, -0.25128, -0.46535, 2.1221, -1.76192, -0.46535, 1.86882, 1.75606, -0.424191, -1.35832, 1.81769, 0.88668, -1.35832, -0.616956, -0.424191, -1.35832, -0.616956, -0.46535, 1.86882, -0.6165)
[node name="Person" type="CharacterBody3D"] [node name="Person" type="CharacterBody3D"]
script = ExtResource("1_dh77o") script = ExtResource("1_dh77o")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."] [node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0) transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, 0, 0.368102)
mesh = ExtResource("1_11yxf") mesh = ExtResource("1_11yxf")
surface_material_override/1 = SubResource("ShaderMaterial_kmh38")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0) transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, 0, 0.368102)
shape = SubResource("ConvexPolygonShape3D_dh77o") shape = SubResource("ConvexPolygonShape3D_dbviw")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."] [node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
avoidance_enabled = true avoidance_enabled = true
debug_enabled = true debug_enabled = true
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_navigation_finished"]

View File

@@ -39,7 +39,7 @@ cartTop = NodePath("Cart-top")
mesh = ExtResource("1_ux2tx") mesh = ExtResource("1_ux2tx")
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="Cart-bottom"] [node name="NavigationRegion3D" type="NavigationRegion3D" parent="Cart-bottom"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.55366, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.138559, 0)
navigation_mesh = SubResource("NavigationMesh_ru0md") navigation_mesh = SubResource("NavigationMesh_ru0md")
[node name="NavigationObstacle3D" type="NavigationObstacle3D" parent="Cart-bottom/NavigationRegion3D"] [node name="NavigationObstacle3D" type="NavigationObstacle3D" parent="Cart-bottom/NavigationRegion3D"]

View File

@@ -114,4 +114,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.321, 0.384693, -59.426)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 180.354, 0.385, -59.426) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 180.354, 0.385, -59.426)
[node name="Person" parent="." instance=ExtResource("5_kry3j")] [node name="Person" parent="." instance=ExtResource("5_kry3j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.335692, 3.74189, -60.6947) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.335692, 3.32679, -60.6947)

View File

@@ -1,14 +1,27 @@
extends CharacterBody3D extends CharacterBody3D
var nav_agent: NavigationAgent3D var nav_agent: NavigationAgent3D
var shirt_shader: ShaderMaterial
var meshI: MeshInstance3D
var start_pos: Vector3
func _ready() -> void: func _ready() -> void:
nav_agent = $NavigationAgent3D nav_agent = $NavigationAgent3D
meshI = $MeshInstance3D
shirt_shader = meshI.get_surface_override_material(1)
Global.object_placed.connect(_on_object_placed) Global.object_placed.connect(_on_object_placed)
set_random_shirt()
start_pos = global_position
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942) #nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
var new_velocity = global_position.direction_to(nav_agent.get_next_path_position()) * 5.0 var new_velocity = global_position.direction_to(nav_agent.get_next_path_position()) * 5.0
look_at(nav_agent.target_position)
velocity = new_velocity velocity = new_velocity
move_and_slide() move_and_slide()
@@ -16,3 +29,13 @@ func _physics_process(delta: float) -> void:
func _on_object_placed(): func _on_object_placed():
nav_agent.target_position = Vector3(-14.305,3.486,-59.836) nav_agent.target_position = Vector3(-14.305,3.486,-59.836)
func set_random_shirt():
var new_shirt_color = Vector3(randf(),randf(),randf())
shirt_shader.set_shader_parameter("shirt_color", new_shirt_color)
pass
func _on_navigation_agent_3d_navigation_finished() -> void:
nav_agent.target_position = start_pos

16
Shaders/shirt.gdshader Normal file
View File

@@ -0,0 +1,16 @@
shader_type spatial;
uniform vec3 shirt_color;
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
ALBEDO = shirt_color;
}
//void light() {
// // Called for every pixel for every light affecting the material.
// // Uncomment to replace the default light processing function with this one.
//}

View File

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