add new models and rig and handle multiple navigation region
This commit is contained in:
@@ -4,6 +4,7 @@ class_name AIBase
|
|||||||
|
|
||||||
@export_group("Settings")
|
@export_group("Settings")
|
||||||
@export var speed: float = 4.0
|
@export var speed: float = 4.0
|
||||||
|
@export_flags_3d_navigation var navigation_layers: int = 1
|
||||||
var _enable_state_machine: bool = true
|
var _enable_state_machine: bool = true
|
||||||
@export var enable_state_machine: bool:
|
@export var enable_state_machine: bool:
|
||||||
set(value):
|
set(value):
|
||||||
@@ -26,6 +27,8 @@ enum EntityType { HUMANOID, ANIMAL }
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
randomize()
|
randomize()
|
||||||
|
if nav_agent:
|
||||||
|
nav_agent.navigation_layers = navigation_layers
|
||||||
toggle_enable_state_machine()
|
toggle_enable_state_machine()
|
||||||
|
|
||||||
func toggle_enable_state_machine() -> void:
|
func toggle_enable_state_machine() -> void:
|
||||||
@@ -67,4 +70,6 @@ func navigate_to_random_point() -> void:
|
|||||||
if nav_agent.is_target_reachable():
|
if nav_agent.is_target_reachable():
|
||||||
return
|
return
|
||||||
|
|
||||||
nav_agent.target_position = global_position
|
# Fallback: if we can't find a reachable point (e.g. we drifted slightly off navmesh),
|
||||||
|
# try to navigate to the closest navmesh point to our CURRENT position to get unstuck.
|
||||||
|
nav_agent.target_position = NavigationServer3D.map_get_closest_point(nav_map_rid, global_position)
|
||||||
|
|||||||
BIN
core/ai/agents/cat/Cat_rig.fbx
Normal file
BIN
core/ai/agents/cat/Cat_rig.fbx
Normal file
Binary file not shown.
4159
core/ai/agents/cat/Cat_rig.fbx.import
Normal file
4159
core/ai/agents/cat/Cat_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
60
core/ai/agents/cat/ai_cat.tscn
Normal file
60
core/ai/agents/cat/ai_cat.tscn
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
[gd_scene format=3 uid="uid://duppccreftg3v"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_85o24"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_6mu8r"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c5rccx22gs6jt" path="res://core/ai/agents/cat/Cat_rig.fbx" id="2_rohxe"]
|
||||||
|
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_0jm3k"]
|
||||||
|
|
||||||
|
[node name="AiCat" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_85o24")]
|
||||||
|
anim_player = NodePath("Cat_rig/AnimationPlayer")
|
||||||
|
entity_type = 1
|
||||||
|
entity_name = "Cat"
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("IdleState")
|
||||||
|
|
||||||
|
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1884542620]
|
||||||
|
script = ExtResource("2_6mu8r")
|
||||||
|
state_id = &"idle"
|
||||||
|
next_state_id = &"patrol"
|
||||||
|
animation_name = "Cat_Idle"
|
||||||
|
|
||||||
|
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1861645340]
|
||||||
|
script = ExtResource("3_0jm3k")
|
||||||
|
state_id = &"patrol"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "Cat_Walk"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="Cat_rig" parent="." index="3" unique_id=1332997618 instance=ExtResource("2_rohxe")]
|
||||||
|
|
||||||
|
[node name="Skeleton3D" parent="Cat_rig/Rig_Cat" parent_id_path=PackedInt32Array(1332997618, 1292226211) index="0" unique_id=807490174]
|
||||||
|
bones/1/position = Vector3(1.6719584e-08, 0.23547882, 0.34218493)
|
||||||
|
bones/1/rotation = Quaternion(0.12769094, -0.6954821, -0.12769029, 0.69548184)
|
||||||
|
bones/2/rotation = Quaternion(-1.5819447e-07, -1.9079575e-07, -0.5904159, 0.8070992)
|
||||||
|
bones/3/position = Vector3(0.21655759, -1.1490099e-06, 4.6904738e-08)
|
||||||
|
bones/3/rotation = Quaternion(4.4475364e-08, -1.16689236e-07, 0.042394996, 0.999101)
|
||||||
|
bones/4/rotation = Quaternion(4.694551e-09, 1.2888964e-07, 0.30337927, 0.9528699)
|
||||||
|
bones/7/rotation = Quaternion(9.573777e-09, -1.3302474e-07, -0.40028554, 0.9163905)
|
||||||
|
bones/9/rotation = Quaternion(0.0005057682, -0.00040186392, -0.7732871, 0.63405573)
|
||||||
|
bones/10/rotation = Quaternion(7.318899e-08, 1.07771655e-07, 0.23513123, 0.97196364)
|
||||||
|
bones/11/rotation = Quaternion(-0.013215952, -0.0063107302, 0.33804607, 0.9410156)
|
||||||
|
bones/13/rotation = Quaternion(-0.00018823319, 2.7849663e-05, -0.77314246, 0.6342325)
|
||||||
|
bones/14/rotation = Quaternion(7.324482e-08, 1.0779509e-07, 0.23506226, 0.9719804)
|
||||||
|
bones/15/rotation = Quaternion(0.01474526, 0.007664346, 0.33750835, 0.94117594)
|
||||||
|
bones/17/rotation = Quaternion(0.06574773, -0.012684476, 0.9796892, 0.18901183)
|
||||||
|
bones/18/rotation = Quaternion(-0.046865243, -0.04779876, -0.69851494, 0.7124576)
|
||||||
|
bones/19/position = Vector3(0.18072681, -0.041122876, -4.2319297e-08)
|
||||||
|
bones/19/rotation = Quaternion(-0.0051541063, -0.0666377, -0.080000654, 0.9945516)
|
||||||
|
bones/21/rotation = Quaternion(1.2657155e-07, 4.030732e-07, 0.96184576, -0.27359232)
|
||||||
|
bones/22/position = Vector3(0.0749221, -0.0072982265, -0.03856178)
|
||||||
|
bones/22/rotation = Quaternion(-8.139895e-08, 1.15607975e-07, -0.47071916, 0.88228315)
|
||||||
|
bones/23/position = Vector3(0.18089643, -0.000116025236, -0.011642921)
|
||||||
|
bones/23/rotation = Quaternion(2.998039e-07, -1.6746765e-07, 0.5290288, 0.84860384)
|
||||||
|
bones/26/position = Vector3(-0.03817617, 0.03956073, 0.04669925)
|
||||||
|
bones/26/rotation = Quaternion(-3.380398e-05, -0.00016875651, 0.9618461, -0.27359122)
|
||||||
|
bones/27/rotation = Quaternion(-8.140452e-08, 1.1560887e-07, -0.47071794, 0.8822838)
|
||||||
|
bones/28/position = Vector3(0.18089616, -0.000116375166, 0.011642809)
|
||||||
|
bones/28/rotation = Quaternion(4.5638826e-05, -8.8217595e-05, 0.5290293, 0.84860367)
|
||||||
|
|
||||||
|
[editable path="Cat_rig"]
|
||||||
BIN
core/ai/agents/crow/Crow_rig.fbx
Normal file
BIN
core/ai/agents/crow/Crow_rig.fbx
Normal file
Binary file not shown.
4159
core/ai/agents/crow/Crow_rig.fbx.import
Normal file
4159
core/ai/agents/crow/Crow_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
25
core/ai/agents/crow/ai_crow.tscn
Normal file
25
core/ai/agents/crow/ai_crow.tscn
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cxi6phs4fieli"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_tx3nx"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dfdeepw5p5nb8" path="res://core/ai/agents/crow/Crow_rig.fbx" id="2_1pxwy"]
|
||||||
|
[ext_resource type="Script" uid="uid://da5vhmxbxkdbc" path="res://core/ai/framework/wait_train_state.gd" id="3_wait"]
|
||||||
|
[ext_resource type="Script" uid="uid://tys4fmqvneom" path="res://core/ai/framework/fly_away_state.gd" id="4_fly"]
|
||||||
|
|
||||||
|
[node name="AiCrow" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_tx3nx")]
|
||||||
|
anim_player = NodePath("Crow_rig/AnimationPlayer")
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("WaitTrainState")
|
||||||
|
|
||||||
|
[node name="WaitTrainState" type="Node" parent="StateMachine" index="0" unique_id=1000000000]
|
||||||
|
script = ExtResource("3_wait")
|
||||||
|
state_id = &"wait"
|
||||||
|
next_state_id = &"fly"
|
||||||
|
animation_name = "Idle_Crow"
|
||||||
|
|
||||||
|
[node name="FlyAwayState" type="Node" parent="StateMachine" index="1" unique_id=1000000001]
|
||||||
|
script = ExtResource("4_fly")
|
||||||
|
state_id = &"fly"
|
||||||
|
animation_name = "Fly_Crow"
|
||||||
|
|
||||||
|
[node name="Crow_rig" parent="." index="3" unique_id=2141026440 instance=ExtResource("2_1pxwy")]
|
||||||
BIN
core/ai/agents/fox/Fox_rig.fbx
Normal file
BIN
core/ai/agents/fox/Fox_rig.fbx
Normal file
Binary file not shown.
6215
core/ai/agents/fox/Fox_rig.fbx.import
Normal file
6215
core/ai/agents/fox/Fox_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
61
core/ai/agents/fox/ai_fox.tscn
Normal file
61
core/ai/agents/fox/ai_fox.tscn
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bk45etvtdd6m5"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_m3efo"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_58gnd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://4y4tffc723lg" path="res://core/ai/agents/fox/Fox_rig.fbx" id="2_xaafp"]
|
||||||
|
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_d1sp2"]
|
||||||
|
[ext_resource type="Script" uid="uid://b5y4u0itec8g1" path="res://core/ai/framework/run_state.gd" id="4_d1sp2"]
|
||||||
|
|
||||||
|
[node name="AiFox" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_m3efo")]
|
||||||
|
anim_player = NodePath("Fox_rig/AnimationPlayer")
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("IdleState")
|
||||||
|
|
||||||
|
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=933090954]
|
||||||
|
script = ExtResource("2_58gnd")
|
||||||
|
state_id = &"idle"
|
||||||
|
next_state_id = &"patrol"
|
||||||
|
random_next_state_ids = Array[StringName]([&"patrol", &"run"])
|
||||||
|
animation_name = "Idle_Fox"
|
||||||
|
|
||||||
|
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=48187684]
|
||||||
|
script = ExtResource("3_d1sp2")
|
||||||
|
state_id = &"patrol"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "Walk_Fox"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="RunState" type="Node" parent="StateMachine" index="2" unique_id=30664919]
|
||||||
|
script = ExtResource("4_d1sp2")
|
||||||
|
state_id = &"run"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "Run_Fox"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="Fox_rig" parent="." index="3" unique_id=2044859181 instance=ExtResource("2_xaafp")]
|
||||||
|
|
||||||
|
[node name="Skeleton3D" parent="Fox_rig/Rig_Fox" parent_id_path=PackedInt32Array(2044859181, 1371677834) index="0" unique_id=625291101]
|
||||||
|
bones/1/position = Vector3(1.2443564e-08, 0.24551632, 0.408434)
|
||||||
|
bones/1/rotation = Quaternion(0.12769088, -0.6954821, -0.12769023, 0.69548184)
|
||||||
|
bones/2/rotation = Quaternion(-1.492881e-07, -1.7862074e-07, -0.5904159, 0.8070992)
|
||||||
|
bones/3/rotation = Quaternion(4.4853135e-08, 2.4038487e-09, 0.042394996, 0.999101)
|
||||||
|
bones/4/rotation = Quaternion(-3.9116873e-08, 1.0805254e-08, 0.30337915, 0.95286995)
|
||||||
|
bones/7/rotation = Quaternion(6.614782e-08, -2.2280902e-08, -0.4002855, 0.9163905)
|
||||||
|
bones/9/rotation = Quaternion(0.00050595123, -0.00040185585, -0.7732871, 0.63405573)
|
||||||
|
bones/10/rotation = Quaternion(4.4809266e-08, -6.81585e-09, 0.23513126, 0.97196364)
|
||||||
|
bones/11/rotation = Quaternion(-0.013216025, -0.0063106352, 0.33804604, 0.94101566)
|
||||||
|
bones/13/rotation = Quaternion(-0.00018805025, 2.7857828e-05, -0.77314246, 0.6342325)
|
||||||
|
bones/14/rotation = Quaternion(4.4874945e-08, -6.797017e-09, 0.23506236, 0.9719803)
|
||||||
|
bones/15/rotation = Quaternion(0.014745249, 0.00766435, 0.33750823, 0.9411759)
|
||||||
|
bones/17/rotation = Quaternion(0.06574762, -0.012684453, 0.9796892, 0.18901181)
|
||||||
|
bones/18/rotation = Quaternion(-0.0045532905, -0.06678549, -0.06784821, 0.99544746)
|
||||||
|
bones/19/rotation = Quaternion(-0.00312141, -0.06676418, -0.049661905, 0.99652725)
|
||||||
|
bones/21/rotation = Quaternion(-5.0142333e-08, 4.1612444e-07, 0.9618458, -0.27359205)
|
||||||
|
bones/22/rotation = Quaternion(-1.9314905e-08, 4.503425e-08, -0.47071874, 0.88228333)
|
||||||
|
bones/23/rotation = Quaternion(1.5250623e-07, -2.2114624e-07, 0.5290283, 0.84860426)
|
||||||
|
bones/26/rotation = Quaternion(-3.3980676e-05, -0.00016874354, 0.9618461, -0.27359122)
|
||||||
|
bones/27/rotation = Quaternion(-1.9324155e-08, 4.5031282e-08, -0.47071794, 0.8822838)
|
||||||
|
bones/28/rotation = Quaternion(4.549153e-05, -8.8271285e-05, 0.5290293, 0.84860367)
|
||||||
|
|
||||||
|
[editable path="Fox_rig"]
|
||||||
BIN
core/ai/agents/goat/Goat_rig.fbx
Normal file
BIN
core/ai/agents/goat/Goat_rig.fbx
Normal file
Binary file not shown.
4159
core/ai/agents/goat/Goat_rig.fbx.import
Normal file
4159
core/ai/agents/goat/Goat_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
52
core/ai/agents/goat/ai_goat.tscn
Normal file
52
core/ai/agents/goat/ai_goat.tscn
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
[gd_scene format=3 uid="uid://c8e8vy2yx0vuj"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_f7hhh"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cumnmnbdjbgas" path="res://core/ai/agents/goat/Goat_rig.fbx" id="2_oxwbf"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_ucoix"]
|
||||||
|
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_lqqd8"]
|
||||||
|
|
||||||
|
[node name="AiGoat" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_f7hhh")]
|
||||||
|
anim_player = NodePath("Goat_rig/AnimationPlayer")
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("IdleState")
|
||||||
|
|
||||||
|
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=874855696]
|
||||||
|
script = ExtResource("2_ucoix")
|
||||||
|
state_id = &"idle"
|
||||||
|
next_state_id = &"patrol"
|
||||||
|
animation_name = "Goat_Idle"
|
||||||
|
|
||||||
|
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=450542027]
|
||||||
|
script = ExtResource("3_lqqd8")
|
||||||
|
state_id = &"patrol"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "Goat_Walk"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="Goat_rig" parent="." index="3" unique_id=1336829719 instance=ExtResource("2_oxwbf")]
|
||||||
|
|
||||||
|
[node name="Skeleton3D" parent="Goat_rig/Rig_Goat" parent_id_path=PackedInt32Array(1336829719, 1896192446) index="0" unique_id=1573667924]
|
||||||
|
bones/1/position = Vector3(-8.352713e-09, 0.36986786, 0.8951362)
|
||||||
|
bones/1/rotation = Quaternion(0.1276911, -0.695482, -0.12769035, 0.69548184)
|
||||||
|
bones/2/rotation = Quaternion(-8.7811394e-08, -9.458198e-08, -0.5904155, 0.80709946)
|
||||||
|
bones/3/rotation = Quaternion(4.747651e-08, -1.1784627e-07, 0.017411958, 0.9998484)
|
||||||
|
bones/4/rotation = Quaternion(6.0150165e-09, 1.2466938e-07, 0.30337915, 0.95287)
|
||||||
|
bones/7/rotation = Quaternion(5.4816347e-08, -2.1401915e-08, -0.40028566, 0.9163904)
|
||||||
|
bones/9/rotation = Quaternion(0.00046716904, -0.0004462793, -0.7121794, 0.7019972)
|
||||||
|
bones/10/rotation = Quaternion(1.4472131e-07, 8.2933745e-08, 0.037125967, 0.9993106)
|
||||||
|
bones/11/rotation = Quaternion(-0.012037385, -0.007822092, 0.4605625, 0.8875113)
|
||||||
|
bones/13/rotation = Quaternion(0.0004971335, -0.00088232313, -0.7120875, 0.70209)
|
||||||
|
bones/14/rotation = Quaternion(1.2098344e-07, 6.220867e-08, 0.03712596, 0.9993106)
|
||||||
|
bones/15/rotation = Quaternion(0.016517974, 0.014013905, 0.46007547, 0.8876156)
|
||||||
|
bones/17/rotation = Quaternion(5.284289e-08, 2.4923622e-07, 0.98189294, 0.1894366)
|
||||||
|
bones/18/rotation = Quaternion(-1.4809112e-07, -6.559211e-08, -0.4198785, 0.9075803)
|
||||||
|
bones/19/rotation = Quaternion(-2.2811262e-09, 1.0970184e-07, 0.011576452, 0.999933)
|
||||||
|
bones/21/rotation = Quaternion(3.0247494e-07, 7.4317376e-07, 0.9653871, -0.26082122)
|
||||||
|
bones/22/rotation = Quaternion(-3.8364158e-07, 5.6172302e-09, -0.3680436, 0.92980856)
|
||||||
|
bones/23/rotation = Quaternion(0.0002487348, 5.1511866e-05, 0.45848387, 0.8887027)
|
||||||
|
bones/26/rotation = Quaternion(2.713829e-07, 8.5825764e-07, 0.9653876, -0.26081985)
|
||||||
|
bones/27/rotation = Quaternion(-3.8362674e-07, 5.6200027e-09, -0.3680436, 0.92980856)
|
||||||
|
bones/28/rotation = Quaternion(-0.00015313082, -7.842175e-05, 0.45790914, 0.888999)
|
||||||
|
|
||||||
|
[editable path="Goat_rig"]
|
||||||
@@ -37,7 +37,7 @@ exit_on_action_finished = true
|
|||||||
[node name="HorseMannequin" parent="." index="3" unique_id=1289880358 instance=ExtResource("2_4t6jw")]
|
[node name="HorseMannequin" parent="." index="3" unique_id=1289880358 instance=ExtResource("2_4t6jw")]
|
||||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
|
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
|
||||||
|
|
||||||
[node name="Skeleton3D" parent="HorseMannequin/Armature" parent_id_path=PackedInt32Array(1289880358, 1841497289) index="0" unique_id=1502661928]
|
[node name="Skeleton3D" parent="HorseMannequin/Armature" parent_id_path=PackedInt32Array(1289880358, 245823720) index="0" unique_id=494955820]
|
||||||
bones/1/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
|
bones/1/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
|
||||||
bones/4/rotation = Quaternion(0.0012952884, -0.0012955684, 0.7071056, 0.7071057)
|
bones/4/rotation = Quaternion(0.0012952884, -0.0012955684, 0.7071056, 0.7071057)
|
||||||
bones/5/rotation = Quaternion(0.70685357, -0.70227593, -0.04508998, 0.07164877)
|
bones/5/rotation = Quaternion(0.70685357, -0.70227593, -0.04508998, 0.07164877)
|
||||||
@@ -65,7 +65,7 @@ bones/33/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.707106
|
|||||||
bones/35/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
|
bones/35/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
|
||||||
bones/37/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
|
bones/37/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
|
||||||
|
|
||||||
[node name="AnimationPlayer" parent="HorseMannequin" index="1" unique_id=1876493257]
|
[node name="AnimationPlayer" parent="HorseMannequin" index="1" unique_id=272680130]
|
||||||
libraries/custom = SubResource("AnimationLibrary_or6xs")
|
libraries/custom = SubResource("AnimationLibrary_or6xs")
|
||||||
|
|
||||||
[editable path="HorseMannequin"]
|
[editable path="HorseMannequin"]
|
||||||
|
|||||||
BIN
core/ai/agents/racoon/Raccoon_rig.fbx
Normal file
BIN
core/ai/agents/racoon/Raccoon_rig.fbx
Normal file
Binary file not shown.
4159
core/ai/agents/racoon/Raccoon_rig.fbx.import
Normal file
4159
core/ai/agents/racoon/Raccoon_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
99
core/ai/agents/racoon/ai_racoon.tscn
Normal file
99
core/ai/agents/racoon/ai_racoon.tscn
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dgpkoccwlypct"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_seif5"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_c6y48"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b3s7f6ntc8lua" path="res://core/ai/agents/racoon/Raccoon_rig.fbx" id="2_obtl0"]
|
||||||
|
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_x67t3"]
|
||||||
|
|
||||||
|
[node name="AiRacoon" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_seif5")]
|
||||||
|
anim_player = NodePath("Raccoon_rig/AnimationPlayer")
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("IdleState")
|
||||||
|
|
||||||
|
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=445061494]
|
||||||
|
script = ExtResource("2_c6y48")
|
||||||
|
state_id = &"idle"
|
||||||
|
next_state_id = &"patrol"
|
||||||
|
animation_name = "Raccoon_Idle"
|
||||||
|
|
||||||
|
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1096336671]
|
||||||
|
script = ExtResource("3_x67t3")
|
||||||
|
state_id = &"patrol"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "Raccoon_walk"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="Raccoon_rig" parent="." index="3" unique_id=338211330 instance=ExtResource("2_obtl0")]
|
||||||
|
|
||||||
|
[node name="Skeleton3D" parent="Raccoon_rig/Rig_Raccoon" parent_id_path=PackedInt32Array(338211330, 1484615769) index="0" unique_id=689430915]
|
||||||
|
bones/1/position = Vector3(2.0224038e-08, 0.20926544, 0.2908604)
|
||||||
|
bones/1/rotation = Quaternion(0.12769087, -0.6954821, -0.12769023, 0.69548184)
|
||||||
|
bones/1/scale = Vector3(1, 0.99999994, 0.99999994)
|
||||||
|
bones/2/position = Vector3(0.12958723, 0.07514775, -1.15517205e-08)
|
||||||
|
bones/2/rotation = Quaternion(-8.768937e-08, -9.441525e-08, -0.59041584, 0.8070993)
|
||||||
|
bones/2/scale = Vector3(0.99999994, 1, 1)
|
||||||
|
bones/3/position = Vector3(0.22119753, 0.0069588325, 4.8590223e-08)
|
||||||
|
bones/3/rotation = Quaternion(4.7472064e-08, -1.1799982e-07, 0.017411917, 0.9998484)
|
||||||
|
bones/3/scale = Vector3(1, 0.99999994, 1)
|
||||||
|
bones/4/position = Vector3(0.19968472, -0.07484539, -3.6076216e-08)
|
||||||
|
bones/4/rotation = Quaternion(5.3009783e-09, 1.2681039e-07, 0.30337906, 0.95286995)
|
||||||
|
bones/4/scale = Vector3(0.9999999, 0.9999999, 1)
|
||||||
|
bones/5/position = Vector3(-1.6408816e-08, -2.420219e-08, 7.257661e-15)
|
||||||
|
bones/5/rotation = Quaternion(5.51443e-16, 1.517952e-14, 4.7269896e-08, 1)
|
||||||
|
bones/5/scale = Vector3(1.0000001, 1, 1)
|
||||||
|
bones/7/position = Vector3(0.103939, -0.07868026, 2.3476135e-08)
|
||||||
|
bones/7/rotation = Quaternion(9.0738554e-09, -1.3033788e-07, -0.40028542, 0.91639054)
|
||||||
|
bones/7/scale = Vector3(1, 1, 1)
|
||||||
|
bones/9/position = Vector3(0.11748607, -0.13258429, 0.069675714)
|
||||||
|
bones/9/rotation = Quaternion(0.0004671751, -0.00044618634, -0.7121794, 0.7019972)
|
||||||
|
bones/9/scale = Vector3(1, 1, 1)
|
||||||
|
bones/10/position = Vector3(0.12467117, -0.0022201955, -2.8368248e-08)
|
||||||
|
bones/10/rotation = Quaternion(5.363282e-08, 1.05591454e-07, 0.037125982, 0.9993106)
|
||||||
|
bones/10/scale = Vector3(1, 1, 1)
|
||||||
|
bones/11/position = Vector3(0.16112469, 0.046494268, -0.006244522)
|
||||||
|
bones/11/rotation = Quaternion(-0.0120373955, -0.007822201, 0.46056247, 0.8875113)
|
||||||
|
bones/11/scale = Vector3(1.0000001, 0.99999994, 1)
|
||||||
|
bones/13/position = Vector3(0.117486075, -0.1325843, -0.0696799)
|
||||||
|
bones/13/rotation = Quaternion(0.0004971096, -0.00088223023, -0.7120875, 0.70209)
|
||||||
|
bones/13/scale = Vector3(0.9999999, 0.9999999, 1)
|
||||||
|
bones/14/position = Vector3(0.12467118, -0.0022202404, -3.56783e-08)
|
||||||
|
bones/14/rotation = Quaternion(5.3701754e-08, 1.05572354e-07, 0.037125997, 0.9993106)
|
||||||
|
bones/14/scale = Vector3(1.0000001, 1.0000001, 1)
|
||||||
|
bones/15/position = Vector3(0.16112465, 0.04649423, 0.0062444974)
|
||||||
|
bones/15/rotation = Quaternion(0.016517976, 0.014013659, 0.46007556, 0.88761556)
|
||||||
|
bones/15/scale = Vector3(0.9999999, 0.9999999, 1)
|
||||||
|
bones/17/position = Vector3(0.04661899, 0.17346847, -1.18498086e-07)
|
||||||
|
bones/17/rotation = Quaternion(2.770023e-07, 3.177246e-07, 0.99957025, -0.029315341)
|
||||||
|
bones/17/scale = Vector3(1.000003, 1, 1)
|
||||||
|
bones/18/position = Vector3(0.14637275, -0.04410621, -9.865532e-08)
|
||||||
|
bones/18/rotation = Quaternion(-2.6851015e-07, -5.1783097e-08, -0.38697308, 0.92209107)
|
||||||
|
bones/18/scale = Vector3(1, 0.99999994, 1)
|
||||||
|
bones/19/position = Vector3(0.14074759, 0.012081423, -1.07438225e-07)
|
||||||
|
bones/19/rotation = Quaternion(-5.266017e-08, 3.9203155e-07, -0.22906616, 0.9734109)
|
||||||
|
bones/19/scale = Vector3(0.99999994, 1.0000001, 1)
|
||||||
|
bones/21/position = Vector3(0.08406017, 0.07054766, -0.046703663)
|
||||||
|
bones/21/rotation = Quaternion(2.472915e-07, 4.2034915e-07, 0.9653872, -0.26082113)
|
||||||
|
bones/21/scale = Vector3(0.99999994, 1.0000001, 1)
|
||||||
|
bones/22/position = Vector3(0.18519638, 0.014841081, -0.03856185)
|
||||||
|
bones/22/rotation = Quaternion(-1.04219914e-07, 2.4218835e-07, -0.36804387, 0.92980844)
|
||||||
|
bones/23/position = Vector3(0.09934621, 0.042793605, -0.011642947)
|
||||||
|
bones/23/rotation = Quaternion(0.00024863242, 5.0840557e-05, 0.45848417, 0.88870263)
|
||||||
|
bones/23/scale = Vector3(1, 0.9999999, 1)
|
||||||
|
bones/24/position = Vector3(0.10396489, 0.016853496, -0.010173391)
|
||||||
|
bones/24/rotation = Quaternion(9.3242754e-08, 2.4390525e-07, 0.5472883, 0.83694416)
|
||||||
|
bones/24/scale = Vector3(1.0000001, 1.0000001, 1)
|
||||||
|
bones/26/position = Vector3(0.08406015, 0.07054774, 0.046699274)
|
||||||
|
bones/26/rotation = Quaternion(2.1619995e-07, 5.3543306e-07, 0.96538764, -0.2608197)
|
||||||
|
bones/26/scale = Vector3(0.99999994, 1.0000001, 1)
|
||||||
|
bones/27/position = Vector3(0.18519638, 0.014841113, 0.038561605)
|
||||||
|
bones/27/rotation = Quaternion(-1.0420509e-07, 2.4219113e-07, -0.36804387, 0.92980844)
|
||||||
|
bones/27/scale = Vector3(1, 0.9999999, 1)
|
||||||
|
bones/28/position = Vector3(0.09934621, 0.04279366, 0.011642782)
|
||||||
|
bones/28/rotation = Quaternion(-0.00015323279, -7.909327e-05, 0.45790946, 0.8889988)
|
||||||
|
bones/28/scale = Vector3(0.9999999, 0.9999999, 1)
|
||||||
|
bones/29/position = Vector3(0.10396492, 0.01685347, 0.0101733515)
|
||||||
|
bones/29/rotation = Quaternion(6.860365e-08, 2.2637091e-07, 0.5472883, 0.83694416)
|
||||||
|
bones/29/scale = Vector3(1.0000001, 1, 1)
|
||||||
|
|
||||||
|
[editable path="Raccoon_rig"]
|
||||||
BIN
core/ai/agents/wagyu/Wagyu_rig.fbx
Normal file
BIN
core/ai/agents/wagyu/Wagyu_rig.fbx
Normal file
Binary file not shown.
4159
core/ai/agents/wagyu/Wagyu_rig.fbx.import
Normal file
4159
core/ai/agents/wagyu/Wagyu_rig.fbx.import
Normal file
File diff suppressed because it is too large
Load Diff
54
core/ai/agents/wagyu/ai_wagyu.tscn
Normal file
54
core/ai/agents/wagyu/ai_wagyu.tscn
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cp8tf1uitoj57"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_01jto"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_euyvm"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dg6eq5bjdv77x" path="res://core/ai/agents/wagyu/Wagyu_rig.fbx" id="2_kinfw"]
|
||||||
|
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_stslt"]
|
||||||
|
|
||||||
|
[node name="AiWagyu" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_01jto")]
|
||||||
|
anim_player = NodePath("Wagyu_rig/AnimationPlayer")
|
||||||
|
entity_type = 1
|
||||||
|
entity_name = "Wagyu"
|
||||||
|
|
||||||
|
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||||
|
initial_state = NodePath("IdleState")
|
||||||
|
|
||||||
|
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1768876006]
|
||||||
|
script = ExtResource("2_euyvm")
|
||||||
|
state_id = &"idle"
|
||||||
|
next_state_id = &"patrol"
|
||||||
|
animation_name = "wagyu_Idle"
|
||||||
|
|
||||||
|
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1424605081]
|
||||||
|
script = ExtResource("3_stslt")
|
||||||
|
state_id = &"patrol"
|
||||||
|
next_state_id = &"idle"
|
||||||
|
animation_name = "wagyu_walk"
|
||||||
|
exit_on_action_finished = true
|
||||||
|
|
||||||
|
[node name="Wagyu_rig" parent="." index="3" unique_id=434062845 instance=ExtResource("2_kinfw")]
|
||||||
|
|
||||||
|
[node name="Skeleton3D" parent="Wagyu_rig/Rig_wagyu" parent_id_path=PackedInt32Array(434062845, 984050088) index="0" unique_id=1381831503]
|
||||||
|
bones/1/position = Vector3(3.0605813e-06, 0.93198204, 1.5827273)
|
||||||
|
bones/1/rotation = Quaternion(0.12769, -0.69548225, -0.12769146, 0.6954816)
|
||||||
|
bones/2/rotation = Quaternion(-7.474808e-08, -1.0355375e-07, -0.5904155, 0.80709946)
|
||||||
|
bones/3/rotation = Quaternion(4.6805877e-08, -1.1830556e-07, 0.017411785, 0.9998484)
|
||||||
|
bones/4/rotation = Quaternion(1.771281e-08, 1.0884481e-07, 0.19398119, 0.9810053)
|
||||||
|
bones/7/rotation = Quaternion(3.415823e-08, -6.211047e-10, -0.29438308, 0.9556875)
|
||||||
|
bones/9/rotation = Quaternion(0.00046733156, -0.00044638076, -0.7121791, 0.7019975)
|
||||||
|
bones/10/rotation = Quaternion(1.1991547e-07, 8.809733e-08, 0.037125666, 0.9993106)
|
||||||
|
bones/11/rotation = Quaternion(-0.012037467, -0.007821967, 0.46056256, 0.88751113)
|
||||||
|
bones/13/rotation = Quaternion(0.00049730047, -0.0008825069, -0.71208733, 0.7020902)
|
||||||
|
bones/14/rotation = Quaternion(1.5469529e-07, -1.483681e-08, 0.037125666, 0.9993106)
|
||||||
|
bones/15/rotation = Quaternion(0.016517892, 0.014014246, 0.46007577, 0.8876154)
|
||||||
|
bones/17/rotation = Quaternion(9.343425e-08, 2.4610299e-07, 0.9818929, 0.18943687)
|
||||||
|
bones/18/rotation = Quaternion(2.348474e-07, -1.7702094e-07, 0.3209432, 0.9470985)
|
||||||
|
bones/19/rotation = Quaternion(2.0569273e-09, 2.3186735e-07, 0.008903695, 0.99996036)
|
||||||
|
bones/21/rotation = Quaternion(3.5893487e-07, 1.1177136e-06, 0.9652683, -0.2612609)
|
||||||
|
bones/22/rotation = Quaternion(-6.1835095e-07, -2.3081903e-07, -0.36804387, 0.92980844)
|
||||||
|
bones/23/rotation = Quaternion(0.0002490793, 5.1833915e-05, 0.45848417, 0.88870263)
|
||||||
|
bones/26/rotation = Quaternion(3.2779312e-07, 1.2327837e-06, 0.9652686, -0.2612597)
|
||||||
|
bones/27/rotation = Quaternion(-6.191086e-07, -2.305114e-07, -0.36804327, 0.9298087)
|
||||||
|
bones/28/rotation = Quaternion(-0.0001528551, -7.8230434e-05, 0.45790893, 0.8889991)
|
||||||
|
|
||||||
|
[editable path="Wagyu_rig"]
|
||||||
64
core/ai/framework/fly_away_state.gd
Normal file
64
core/ai/framework/fly_away_state.gd
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
extends State
|
||||||
|
|
||||||
|
class_name FlyAwayState
|
||||||
|
|
||||||
|
@export var fly_speed: float = 6.0
|
||||||
|
@export var fly_up_speed: float = 3.0
|
||||||
|
@export var destroy_after_seconds: float = 8.0
|
||||||
|
|
||||||
|
var _timer: float = 0.0
|
||||||
|
var _fly_direction: Vector3 = Vector3.UP
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
super.enter()
|
||||||
|
run_animation()
|
||||||
|
|
||||||
|
# Disable NavigationAgent3D influence since we want manual flight
|
||||||
|
agent.nav_agent.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
|
|
||||||
|
var weather_nodes = get_tree().get_nodes_in_group("weather_node")
|
||||||
|
var train_node = null
|
||||||
|
for node in weather_nodes:
|
||||||
|
if "Treno" in node.name or "Train" in node.name:
|
||||||
|
train_node = node
|
||||||
|
break
|
||||||
|
|
||||||
|
if not train_node:
|
||||||
|
var train = get_tree().root.find_child("*Treno*", true, false)
|
||||||
|
if train and train is Node3D:
|
||||||
|
train_node = train
|
||||||
|
else:
|
||||||
|
train = get_tree().root.find_child("*Train*", true, false)
|
||||||
|
if train and train is Node3D:
|
||||||
|
train_node = train
|
||||||
|
|
||||||
|
if train_node:
|
||||||
|
# Fly away from the train
|
||||||
|
var dir_to_train = agent.global_position.direction_to(train_node.global_position)
|
||||||
|
dir_to_train.y = 0
|
||||||
|
if dir_to_train.length() > 0.1:
|
||||||
|
_fly_direction = -dir_to_train.normalized()
|
||||||
|
else:
|
||||||
|
_fly_direction = -agent.global_transform.basis.z.normalized()
|
||||||
|
else:
|
||||||
|
# If no train found, just fly forward relative to current facing
|
||||||
|
_fly_direction = -agent.global_transform.basis.z.normalized()
|
||||||
|
|
||||||
|
func physics_update(delta: float) -> void:
|
||||||
|
_timer += delta
|
||||||
|
if _timer >= destroy_after_seconds:
|
||||||
|
agent.queue_free()
|
||||||
|
return
|
||||||
|
|
||||||
|
var horizontal_vel = _fly_direction * fly_speed
|
||||||
|
agent.velocity.x = horizontal_vel.x
|
||||||
|
agent.velocity.y = fly_up_speed
|
||||||
|
agent.velocity.z = horizontal_vel.z
|
||||||
|
|
||||||
|
# Rotate agent to face flight direction
|
||||||
|
if horizontal_vel.length_squared() > 0.1:
|
||||||
|
var look_dir = Vector3(agent.velocity.x, 0, agent.velocity.z)
|
||||||
|
var target_transform = agent.global_transform.looking_at(agent.global_position - look_dir, Vector3.UP)
|
||||||
|
agent.global_transform = agent.global_transform.interpolate_with(target_transform, delta * 5.0)
|
||||||
|
|
||||||
|
agent.move_and_slide()
|
||||||
1
core/ai/framework/fly_away_state.gd.uid
Normal file
1
core/ai/framework/fly_away_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://tys4fmqvneom
|
||||||
@@ -7,4 +7,4 @@ func enter() -> void:
|
|||||||
|
|
||||||
func physics_update(_delta) -> void:
|
func physics_update(_delta) -> void:
|
||||||
if agent.nav_agent.is_navigation_finished():
|
if agent.nav_agent.is_navigation_finished():
|
||||||
transitioned.emit(self, next_state_id)
|
transitioned.emit(self, get_next_state())
|
||||||
|
|||||||
18
core/ai/framework/run_state.gd
Normal file
18
core/ai/framework/run_state.gd
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
extends State
|
||||||
|
|
||||||
|
var starting_speed: float
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
super.enter()
|
||||||
|
run_animation()
|
||||||
|
agent.navigate_to_random_point()
|
||||||
|
starting_speed = agent.speed
|
||||||
|
agent.speed = agent.speed * 1.5
|
||||||
|
|
||||||
|
func physics_update(_delta) -> void:
|
||||||
|
if agent.nav_agent.is_navigation_finished():
|
||||||
|
transitioned.emit(self, get_next_state())
|
||||||
|
|
||||||
|
func exit() -> void:
|
||||||
|
agent.speed = starting_speed
|
||||||
|
super.exit()
|
||||||
1
core/ai/framework/run_state.gd.uid
Normal file
1
core/ai/framework/run_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b5y4u0itec8g1
|
||||||
@@ -4,6 +4,7 @@ class_name State
|
|||||||
|
|
||||||
@export var state_id: StringName = &""
|
@export var state_id: StringName = &""
|
||||||
@export var next_state_id: StringName
|
@export var next_state_id: StringName
|
||||||
|
@export var random_next_state_ids: Array[StringName] = []
|
||||||
@export var animation_name: String
|
@export var animation_name: String
|
||||||
@export var exit_on_action_finished: bool
|
@export var exit_on_action_finished: bool
|
||||||
@export var exit_on_animation_finished: bool
|
@export var exit_on_animation_finished: bool
|
||||||
@@ -57,7 +58,12 @@ func _on_animation_finished(anim_name: StringName) -> void:
|
|||||||
var wait_time := randf_range(min_wait_time, max_wait_time)
|
var wait_time := randf_range(min_wait_time, max_wait_time)
|
||||||
runtime_timer.start(wait_time)
|
runtime_timer.start(wait_time)
|
||||||
else:
|
else:
|
||||||
transitioned.emit(self, next_state_id)
|
transitioned.emit(self, get_next_state())
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
transitioned.emit(self, next_state_id)
|
transitioned.emit(self, get_next_state())
|
||||||
|
|
||||||
|
func get_next_state() -> StringName:
|
||||||
|
if random_next_state_ids.size() > 0:
|
||||||
|
return random_next_state_ids.pick_random()
|
||||||
|
return next_state_id
|
||||||
|
|||||||
37
core/ai/framework/wait_train_state.gd
Normal file
37
core/ai/framework/wait_train_state.gd
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
extends State
|
||||||
|
|
||||||
|
class_name WaitTrainState
|
||||||
|
|
||||||
|
@export var fly_distance_threshold: float = 30.0
|
||||||
|
|
||||||
|
var _train_node: Node3D = null
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
super.enter()
|
||||||
|
run_animation()
|
||||||
|
_train_node = _find_train_node()
|
||||||
|
|
||||||
|
func physics_update(_delta: float) -> void:
|
||||||
|
if not _train_node:
|
||||||
|
_train_node = _find_train_node()
|
||||||
|
|
||||||
|
if _train_node:
|
||||||
|
var dist = agent.global_position.distance_to(_train_node.global_position)
|
||||||
|
if dist <= fly_distance_threshold:
|
||||||
|
transitioned.emit(self, get_next_state())
|
||||||
|
|
||||||
|
func _find_train_node() -> Node3D:
|
||||||
|
var weather_nodes = get_tree().get_nodes_in_group("weather_node")
|
||||||
|
for node in weather_nodes:
|
||||||
|
if "Treno" in node.name or "Train" in node.name:
|
||||||
|
return node as Node3D
|
||||||
|
|
||||||
|
var train = get_tree().root.find_child("*Treno*", true, false)
|
||||||
|
if train and train is Node3D:
|
||||||
|
return train as Node3D
|
||||||
|
|
||||||
|
train = get_tree().root.find_child("*Train*", true, false)
|
||||||
|
if train and train is Node3D:
|
||||||
|
return train as Node3D
|
||||||
|
|
||||||
|
return null
|
||||||
1
core/ai/framework/wait_train_state.gd.uid
Normal file
1
core/ai/framework/wait_train_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://da5vhmxbxkdbc
|
||||||
@@ -1,53 +1,38 @@
|
|||||||
[gd_scene format=3 uid="uid://dqvrhiqgkd3w1"]
|
[gd_scene format=3 uid="uid://dqvrhiqgkd3w1"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bnnuke5e7e1yr" path="res://core/ai/agents/human/ai_citizen_walker.tscn" id="1_a2xtd"]
|
[ext_resource type="PackedScene" uid="uid://cp8tf1uitoj57" path="res://core/ai/agents/wagyu/ai_wagyu.tscn" id="2_n3ssi"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ceqxsqfiotm5j" path="res://core/ai/agents/human/ai_farmer.tscn" id="2_n3ssi"]
|
[ext_resource type="PackedScene" uid="uid://c8e8vy2yx0vuj" path="res://core/ai/agents/goat/ai_goat.tscn" id="3_a3kkd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bbseno7clbepx" path="res://core/ai/agents/human/ai_citizen_sitter.tscn" id="3_fdj8t"]
|
[ext_resource type="PackedScene" uid="uid://bk45etvtdd6m5" path="res://core/ai/agents/fox/ai_fox.tscn" id="3_fdj8t"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dd8wn62anbts8" path="res://core/ai/agents/cow/ai_cow.tscn" id="4_wr508"]
|
[ext_resource type="PackedScene" uid="uid://dgpkoccwlypct" path="res://core/ai/agents/racoon/ai_racoon.tscn" id="4_uj4wt"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cayakdk7gmlyg" path="res://core/ai/agents/horse/ai_horse.tscn" id="5_7kg15"]
|
[ext_resource type="PackedScene" uid="uid://duppccreftg3v" path="res://core/ai/agents/cat/ai_cat.tscn" id="9_7kg15"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c2hg6hu2y5srb" path="res://core/ai/agents/pig/ai_pig.tscn" id="6_hw7u7"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://2md4l83fy8kr" path="res://core/ai/agents/pug/ai_pug.tscn" id="7_s6v14"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bs1bdtm7jdtgb" path="res://core/ai/agents/sheep/ai_sheep.tscn" id="8_amn6p"]
|
|
||||||
|
|
||||||
[sub_resource type="NavigationMesh" id="NavigationMesh_optuv"]
|
[sub_resource type="NavigationMesh" id="NavigationMesh_a2xtd"]
|
||||||
vertices = PackedVector3Array(8.984741, 0.25012434, -0.014038086, 9.234741, 0.25012434, -1.0140381, -18.015259, 0.25012434, -18.014038, 17.984741, 0.25012434, 17.985962, 10.984741, 0.25012434, 1.2359619, 9.234741, 0.25012434, 1.2359619, 10.984741, 0.25012434, -1.0140381, 17.984741, 0.25012434, -18.014038, -18.015259, 0.25012434, 17.985962, 11.234741, 0.25012434, 0.23596191)
|
vertices = PackedVector3Array(-19.5, -0.33473957, -19.5, -19.5, -0.33473957, 19.5, 19.5, -0.33473957, 19.5, 19.5, -0.33473957, -19.5)
|
||||||
polygons = [PackedInt32Array(2, 1, 0), PackedInt32Array(5, 4, 3), PackedInt32Array(7, 6, 1), PackedInt32Array(5, 8, 0), PackedInt32Array(0, 8, 2), PackedInt32Array(5, 3, 8), PackedInt32Array(1, 2, 7), PackedInt32Array(3, 4, 9), PackedInt32Array(6, 7, 9), PackedInt32Array(9, 7, 3)]
|
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1)]
|
||||||
border_size = 2.0
|
geometry_source_geometry_mode = 2
|
||||||
|
geometry_source_group_name = &"navigation_mesh_source_group1"
|
||||||
|
|
||||||
|
[sub_resource type="NavigationMesh" id="NavigationMesh_n3ssi"]
|
||||||
|
vertices = PackedVector3Array(0.64679813, -0.33499998, -18.241827, 0.64679813, -0.33499998, 18.258173, 18.146797, -0.33499998, 18.258173, 18.146797, -0.33499998, -18.241827)
|
||||||
|
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1)]
|
||||||
|
geometry_source_geometry_mode = 2
|
||||||
|
geometry_source_group_name = &"navigation_mesh_source_group2"
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id="Environment_lmjyn"]
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_optuv"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_optuv"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xtjak"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_xtjak"]
|
||||||
size = Vector3(1.9942131, 0.09710693, 1.984024)
|
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="GymAI" type="Node3D" unique_id=868339787]
|
||||||
|
|
||||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=774907858]
|
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=774907858]
|
||||||
navigation_mesh = SubResource("NavigationMesh_optuv")
|
navigation_mesh = SubResource("NavigationMesh_a2xtd")
|
||||||
|
|
||||||
[node name="Floor" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=1976415311]
|
[node name="NavigationRegion3D2" type="NavigationRegion3D" parent="." unique_id=527150023 groups=["navigation_mesh_source_group2"]]
|
||||||
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -0.83473957, 0)
|
navigation_mesh = SubResource("NavigationMesh_n3ssi")
|
||||||
mesh = SubResource("PlaneMesh_optuv")
|
navigation_layers = 2
|
||||||
|
|
||||||
[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="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1772424900]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1772424900]
|
||||||
environment = SubResource("Environment_lmjyn")
|
environment = SubResource("Environment_lmjyn")
|
||||||
@@ -93,29 +78,43 @@ Parameters:
|
|||||||
- Area Radius: Radius of the SphereShape3D used by PatrolRadiusShape."
|
- Area Radius: Radius of the SphereShape3D used by PatrolRadiusShape."
|
||||||
autowrap_mode = 2
|
autowrap_mode = 2
|
||||||
|
|
||||||
[node name="AiCitizenWalker" parent="." unique_id=1228675528 instance=ExtResource("1_a2xtd")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.690094, 1, -11.367183)
|
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1753000680]
|
[node name="Camera3D" type="Camera3D" parent="." unique_id=1753000680]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.42261824, 0.9063078, 0, -0.9063078, 0.42261824, 0, 18.361065, 15.377485)
|
transform = Transform3D(1, 0, 0, 0, 0.42261824, 0.9063078, 0, -0.9063078, 0.42261824, 0, 18.361065, 15.377485)
|
||||||
|
|
||||||
[node name="AiFarmer" parent="." unique_id=1839077075 instance=ExtResource("2_n3ssi")]
|
[node name="Floor" type="MeshInstance3D" parent="." unique_id=1976415311 groups=["navigation_mesh_source_group1"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.2447205, 0.94226265, 2.9251099)
|
transform = Transform3D(9.719975, 0, 0, 0, 20, 0, 0, 0, 20, -9.556898, -0.83473957, 0)
|
||||||
|
mesh = SubResource("PlaneMesh_optuv")
|
||||||
|
|
||||||
[node name="AiCitizenSitter" parent="." unique_id=127569260 instance=ExtResource("3_fdj8t")]
|
[node name="StaticBody3D" type="StaticBody3D" parent="Floor" unique_id=2007477719]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.074956, 1.3552468, 11.883549)
|
|
||||||
|
|
||||||
[node name="AiCow" parent="." unique_id=1021070481 instance=ExtResource("4_wr508")]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor/StaticBody3D" unique_id=1446628130]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.4981034, 0.94226265, 15.013644)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0036563873, -0.009703338, -0.00868988)
|
||||||
|
shape = SubResource("BoxShape3D_xtjak")
|
||||||
|
|
||||||
[node name="AiHorse" parent="." unique_id=71046494 instance=ExtResource("5_7kg15")]
|
[node name="Floor2" type="MeshInstance3D" parent="." unique_id=309377168 groups=["navigation_mesh_source_group2"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.385908, 0.94226265, 14.142443)
|
transform = Transform3D(9.282202, 0, 0, 0, 20, 0, 0, 0, 18.741827, 9.429, -0.835, 0)
|
||||||
|
mesh = SubResource("PlaneMesh_optuv")
|
||||||
|
|
||||||
[node name="AiPig" parent="." unique_id=430569938 instance=ExtResource("6_hw7u7")]
|
[node name="StaticBody3D" type="StaticBody3D" parent="Floor2" unique_id=1058766942]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.327689, 0.94226265, 6.6309185)
|
|
||||||
|
|
||||||
[node name="AiPug" parent="." unique_id=1284695236 instance=ExtResource("7_s6v14")]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor2/StaticBody3D" unique_id=2111078072]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.4858246, 0.9422617, 9.294181)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0036563873, -0.009703338, -0.00868988)
|
||||||
|
shape = SubResource("BoxShape3D_xtjak")
|
||||||
|
|
||||||
[node name="AiSheep" parent="." unique_id=806542551 instance=ExtResource("8_amn6p")]
|
[node name="AiGoat" parent="." unique_id=1397968422 instance=ExtResource("3_a3kkd")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.740941, 1.1779783, 16.328548)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.125751, 0, 9.623213)
|
||||||
|
navigation_layers = 2
|
||||||
|
|
||||||
|
[node name="AiRacoon" parent="." unique_id=170783736 instance=ExtResource("4_uj4wt")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.993821, 0, 3.241497)
|
||||||
|
navigation_layers = 2
|
||||||
|
|
||||||
|
[node name="AiWagyu" parent="." unique_id=1980932035 instance=ExtResource("2_n3ssi")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.6312037, 0, -2.8999653)
|
||||||
|
navigation_layers = 2
|
||||||
|
|
||||||
|
[node name="AiCat" parent="." unique_id=1228675528 instance=ExtResource("9_7kg15")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13, 0, 12)
|
||||||
|
|
||||||
|
[node name="AiFox" parent="." unique_id=1674280877 instance=ExtResource("3_fdj8t")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9, 0, 6)
|
||||||
|
|||||||
Reference in New Issue
Block a user