Files
tgcc/docs/gyms/ai/gym_ai.tscn

95 lines
4.6 KiB
Plaintext

[gd_scene format=3 uid="uid://dqvrhiqgkd3w1"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_a2xtd"]
[sub_resource type="NavigationMesh" id="NavigationMesh_optuv"]
vertices = PackedVector3Array(10.984741, 0.25012434, -1.0140381, 11.234741, 0.25012434, 0.23596191, 19.484741, 0.25012434, 0.23596191, 19.484741, 0.25012434, -19.514038, 9.234741, 0.25012434, -1.0140381, -19.515259, 0.25012434, -19.514038, -19.515259, 0.25012434, -0.014038086, 8.984741, 0.25012434, -0.014038086, 10.984741, 0.25012434, 1.2359619, 19.484741, 0.25012434, 19.235962, 9.234741, 0.25012434, 1.2359619, -19.515259, 0.25012434, 19.235962)
polygons = [PackedInt32Array(1, 0, 2), PackedInt32Array(2, 0, 3), PackedInt32Array(6, 5, 4), PackedInt32Array(4, 5, 3), PackedInt32Array(3, 0, 4), PackedInt32Array(4, 7, 6), PackedInt32Array(1, 2, 8), PackedInt32Array(8, 2, 9), PackedInt32Array(6, 10, 11), PackedInt32Array(11, 10, 9), PackedInt32Array(10, 8, 9), PackedInt32Array(6, 7, 10)]
[sub_resource type="PlaneMesh" id="PlaneMesh_optuv"]
[sub_resource type="BoxShape3D" id="BoxShape3D_xtjak"]
size = Vector3(1.9942131, 0.09710693, 1.984024)
[sub_resource type="BoxMesh" id="BoxMesh_lmjyn"]
[sub_resource type="BoxShape3D" id="BoxShape3D_lmjyn"]
[sub_resource type="Environment" id="Environment_lmjyn"]
[node name="GymAI" type="Node3D" unique_id=868339787]
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=774907858]
navigation_mesh = SubResource("NavigationMesh_optuv")
[node name="Floor" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=1976415311]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -0.83473957, 0)
mesh = SubResource("PlaneMesh_optuv")
[node name="StaticBody3D" type="StaticBody3D" parent="NavigationRegion3D/Floor" unique_id=2007477719]
[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationRegion3D/Floor/StaticBody3D" unique_id=1446628130]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0036563873, -0.009703338, -0.00868988)
shape = SubResource("BoxShape3D_xtjak")
[node name="Obstacle" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=710701082]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10.148018, 0.06508446, 0)
mesh = SubResource("BoxMesh_lmjyn")
[node name="StaticBody3D" type="StaticBody3D" parent="NavigationRegion3D/Obstacle" unique_id=67152580]
[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationRegion3D/Obstacle/StaticBody3D" unique_id=1663742898]
shape = SubResource("BoxShape3D_lmjyn")
[node name="AIBase" parent="." unique_id=1228675528 instance=ExtResource("1_a2xtd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.48246834, 0.21202153, 0.11262059)
speed = 5.0
enable_state_machine = true
[node name="Camera3D" type="Camera3D" parent="." unique_id=1148396057]
transform = Transform3D(-2.0613477e-08, 0.8818225, -0.47158146, 3.854569e-08, 0.47158146, 0.8818225, 1, -3.5527137e-15, -4.371139e-08, -18.21907, 28.71355, 0)
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1772424900]
environment = SubResource("Environment_lmjyn")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=269230449]
transform = Transform3D(1, 0, 0, 0, 0.17952333, 0.98375374, 0, -0.98375374, 0.17952333, 0, 18.920979, 0)
[node name="Control" type="Control" parent="." unique_id=1072240389]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1647272132]
layout_mode = 0
offset_left = 50.0
offset_top = 50.0
offset_right = 400.0
offset_bottom = 827.0
[node name="Label" type="Label" parent="Control/PanelContainer" unique_id=272421245]
custom_minimum_size = Vector2(1, 1)
layout_mode = 2
size_flags_vertical = 1
text = "System Logic:
- The NPC uses a finite state machine to switch between behaviors.
- State logic runs during physics updates, while movement is handled by the agent through NavigationAgent3D.
AI States:
- IdleState: The agent waits in place for the duration defined by wait_time.
- PatrolState: The agent selects a valid random destination and moves toward it.
Core Components:
- NavigationAgent3D: Calculates the path and reports when the destination has been reached.
- PatrolRadiusShape: Defines the random movement area used when choosing the next patrol point.
- StateMachine: Initializes the available states and handles transitions between them.
Parameters:
- Speed: Movement speed of the agent.
- Wait Time: Delay in seconds on the IdleState node.
- Area Radius: Radius of the SphereShape3D used by PatrolRadiusShape."
autowrap_mode = 2