add human fbx and idle/walking animation

This commit is contained in:
2026-05-18 23:23:55 +02:00
parent fcab02469a
commit 1adc0ef5b7
14 changed files with 6485 additions and 8 deletions

View File

@@ -11,12 +11,12 @@ var _enable_state_machine: bool = true
get:
return _enable_state_machine
@export var anim_player: AnimationPlayer
@onready var patrol_radius_shape: CollisionShape3D = $%PatrolRadiusShape
@onready var nav_agent: NavigationAgent3D = $%NavigationAgent3D
@onready var state_machine: StateMachine = $%StateMachine
func _ready() -> void:
randomize()
toggle_enable_state_machine()
@@ -41,6 +41,11 @@ func _physics_process(delta: float) -> void:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
if velocity.length_squared() > 0.1:
var look_dir = Vector3(velocity.x, 0, velocity.z)
var target_transform = global_transform.looking_at(global_position - look_dir, Vector3.UP)
global_transform = global_transform.interpolate_with(target_transform, delta * 10.0)
move_and_slide()
func navigate_to_random_point() -> void:
@@ -49,3 +54,15 @@ func navigate_to_random_point() -> void:
var target_point_in_space = global_position + Vector3(randf_range(-1, 1), 0, randf_range(-1, 1)).normalized() * randf_range(0, patrol_radius)
var closest_valid_point = NavigationServer3D.map_get_closest_point(nav_map_rid, target_point_in_space)
nav_agent.target_position = closest_valid_point
func run_walking_animation() -> void:
if anim_player and anim_player.has_animation("custom/walking"):
var anim = anim_player.get_animation("custom/walking")
anim.loop_mode = Animation.LOOP_LINEAR
anim_player.play("custom/walking")
func run_idle_animation() -> void:
if anim_player and anim_player.has_animation("custom/idle"):
var anim = anim_player.get_animation("custom/idle")
anim.loop_mode = Animation.LOOP_LINEAR
anim_player.play("custom/idle")

View File

@@ -2,11 +2,13 @@ extends State
const PATROL_STATE_ID: StringName = &"patrol"
@onready var agent: AIBase = owner
@export var wait_time: float = 3.0
var runtime_timer: Timer
func enter() -> void:
agent.run_idle_animation()
runtime_timer = Timer.new()
runtime_timer.name = "IdleTimer"
add_child(runtime_timer)

View File

@@ -6,6 +6,7 @@ const IDLE_STATE_ID: StringName = &"idle"
func enter() -> void:
agent.navigate_to_random_point()
agent.run_walking_animation()
func physics_update(_delta) -> void:
if agent.nav_agent.is_navigation_finished():

View File

@@ -0,0 +1,58 @@
[gd_scene format=3 uid="uid://mvh2v6v72stt"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_hko2w"]
[ext_resource type="PackedScene" uid="uid://legcajdd0jsy" path="res://core/ai/agents/human/human_mannequin.tscn" id="2_cnrgi"]
[node name="AiHuman" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_hko2w")]
anim_player = NodePath("Human_Walking/AnimationPlayer")
[node name="MeshInstance3D" parent="." index="0" unique_id=214482161]
visible = false
[node name="Human_Walking" parent="." index="5" unique_id=333236377 instance=ExtResource("2_cnrgi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)
[node name="SK_Mannequin" parent="Human_Walking" index="0" unique_id=377304892]
transform = Transform3D(0.99999994, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
[node name="Skeleton3D" parent="Human_Walking/SK_Mannequin" index="0" unique_id=427572412]
bones/2/rotation = Quaternion(-2.1971985e-24, 0, -0.062388558, 0.99805194)
bones/3/rotation = Quaternion(4.135903e-25, 1.6543612e-24, 0.12241964, 0.99247843)
bones/4/rotation = Quaternion(2.2850868e-23, 0, 0.024252614, 0.9997059)
bones/5/rotation = Quaternion(0.20891805, 0.7294167, 0.12304399, 0.6396598)
bones/6/rotation = Quaternion(0.11299576, 0.33062968, -0.16141911, 0.92296255)
bones/7/rotation = Quaternion(-0.05401651, -0.079182714, -0.26340967, 0.9599103)
bones/8/rotation = Quaternion(-0.61789525, 0.019371983, 0.010653294, 0.7859496)
bones/9/rotation = Quaternion(0.1333045, -0.0031801206, 0.22317973, 0.96561414)
bones/10/rotation = Quaternion(0.012043531, -0.0029058352, 0.10444825, 0.9944532)
bones/12/rotation = Quaternion(0.028522171, -0.05687394, 0.19848494, 0.9780366)
bones/13/rotation = Quaternion(-0.018628873, 0.007972199, 0.10711657, 0.99404)
bones/15/rotation = Quaternion(-0.1295377, -0.18789689, 0.14421311, 0.9628693)
bones/16/rotation = Quaternion(0.010359715, -0.010519396, 0.09774818, 0.9951017)
bones/18/rotation = Quaternion(-0.095480494, -0.116765715, 0.18851167, 0.9704188)
bones/19/rotation = Quaternion(0.00430111, -0.0141675975, 0.11596311, 0.9931432)
bones/21/rotation = Quaternion(0.6303091, 0.37152508, -0.07729015, 0.6772783)
bones/22/rotation = Quaternion(0.0026046867, 0.086798474, 0.13014112, 0.98768544)
bones/26/rotation = Quaternion(0.7294168, -0.20891781, -0.6396598, 0.12304417)
bones/27/rotation = Quaternion(0.11299576, 0.33062968, -0.16141911, 0.92296255)
bones/28/rotation = Quaternion(-0.05401651, -0.079182714, -0.26340967, 0.9599103)
bones/29/rotation = Quaternion(-0.61789525, 0.019371983, 0.010653294, 0.7859496)
bones/30/rotation = Quaternion(0.1333045, -0.0031801206, 0.22317973, 0.96561414)
bones/31/rotation = Quaternion(0.012043531, -0.0029058352, 0.10444825, 0.9944532)
bones/33/rotation = Quaternion(0.028522171, -0.05687394, 0.19848494, 0.9780366)
bones/34/rotation = Quaternion(-0.018628873, 0.007972199, 0.10711657, 0.99404)
bones/36/rotation = Quaternion(-0.1295377, -0.18789689, 0.14421311, 0.9628693)
bones/37/rotation = Quaternion(0.010359715, -0.010519396, 0.09774818, 0.9951017)
bones/39/rotation = Quaternion(-0.095480494, -0.116765715, 0.18851167, 0.9704188)
bones/40/rotation = Quaternion(0.00430111, -0.0141675975, 0.11596311, 0.9931432)
bones/42/rotation = Quaternion(0.6303091, 0.37152508, -0.07729015, 0.6772783)
bones/43/rotation = Quaternion(0.0026047025, 0.08679848, 0.13014114, 0.98768544)
bones/47/rotation = Quaternion(-1.5923227e-23, 0, -0.20371072, 0.97903115)
bones/49/rotation = Quaternion(0.07370486, -0.062138822, -0.008584324, 0.9953053)
bones/50/rotation = Quaternion(-0.048884246, 0.018863896, -0.06552225, 0.99647444)
bones/52/rotation = Quaternion(-0.0058857696, 0.03199128, 0.07035475, 0.9969916)
bones/55/rotation = Quaternion(0.062138822, 0.07370486, 0.9953054, 0.008584333)
bones/56/rotation = Quaternion(-0.048884246, 0.018863896, -0.06552225, 0.99647444)
bones/58/rotation = Quaternion(-0.0058857696, 0.03199128, 0.07035475, 0.9969916)
[editable path="Human_Walking"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
[gd_scene format=3 uid="uid://legcajdd0jsy"]
[ext_resource type="PackedScene" uid="uid://ys8pesrqeyv2" path="res://core/ai/agents/human/human_mannequin_mixamo.fbx" id="1_561x5"]
[ext_resource type="Animation" uid="uid://b2wo1mpqihko6" path="res://core/ai/agents/human/idle.res" id="2_b4vfe"]
[ext_resource type="Animation" uid="uid://cd02fn4tl8pxt" path="res://core/ai/agents/human/walking.res" id="3_jl3mr"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3r4wv"]
_data = {
&"idle": ExtResource("2_b4vfe"),
&"walking": ExtResource("3_jl3mr")
}
[node name="HumanMannequin" unique_id=1583776159 instance=ExtResource("1_561x5")]
[node name="SK_Mannequin" parent="." index="0" unique_id=377304892]
transform = Transform3D(0.9976258, -0.04861942, 0.048771314, -0.04795494, 0.017819177, 0.99869055, -0.049424794, -0.9986584, 0.015445333, -0.05003774, -0.025284957, -0.009851909)
[node name="Skeleton3D" parent="SK_Mannequin" index="0" unique_id=427572412]
bones/2/rotation = Quaternion(0.0031313226, -0.013143469, -0.06403692, 0.9978561)
bones/3/rotation = Quaternion(0.0060529755, -0.0043215775, 0.11905511, 0.9928599)
bones/4/position = Vector3(0.13407329, 0.004204774, -5.584202e-15)
bones/4/rotation = Quaternion(0.005354738, -0.005161587, 0.020867111, 0.9997546)
bones/5/rotation = Quaternion(0.15400349, 0.7897888, 0.010658391, 0.59363556)
bones/6/position = Vector3(0.15784872, 1.4317955e-11, 6.3591354e-11)
bones/6/rotation = Quaternion(0.04945157, 0.4279849, -0.15578857, 0.8888832)
bones/7/position = Vector3(0.3033993, 8.407472e-11, 3.197531e-11)
bones/7/rotation = Quaternion(0.1100848, 0.10641666, -0.25697437, 0.95421225)
bones/8/position = Vector3(0.26975143, 1.572964e-11, -9.6207486e-11)
bones/8/rotation = Quaternion(-0.46975335, -0.009780162, -0.20075577, 0.8596124)
bones/9/rotation = Quaternion(0.11536587, 0.112830326, 0.39687443, 0.9035766)
bones/10/position = Vector3(0.04287498, -2.9850333e-10, 5.048406e-11)
bones/10/rotation = Quaternion(-0.0044350666, 0.31514773, 0.57789063, 0.752798)
bones/11/position = Vector3(0.0339379, 1.1695445e-10, -2.349232e-11)
bones/12/rotation = Quaternion(-0.026846388, 0.13234028, 0.54907507, 0.82479215)
bones/13/position = Vector3(0.046403743, -3.648193e-11, 1.830866e-11)
bones/13/rotation = Quaternion(-0.017277073, 0.20109688, 0.7544296, 0.62457794)
bones/14/position = Vector3(0.036488436, -1.9989443e-10, 1.6076356e-11)
bones/15/rotation = Quaternion(-0.26582807, -0.019897597, 0.63471824, 0.7253084)
bones/16/position = Vector3(0.03570981, 1.8669866e-10, 3.9181436e-12)
bones/16/rotation = Quaternion(0.036874738, -0.06492835, 0.74109465, 0.66723555)
bones/17/position = Vector3(0.029856307, -3.005879e-10, -4.0375425e-11)
bones/18/rotation = Quaternion(-0.1965758, 0.008460626, 0.5697997, 0.7978814)
bones/19/position = Vector3(0.04430177, 4.6665116e-11, -9.4033115e-12)
bones/19/rotation = Quaternion(0.008596869, -0.008138666, 0.79523915, 0.6061805)
bones/20/position = Vector3(0.034766525, -1.6786372e-10, 2.768652e-11)
bones/21/rotation = Quaternion(0.601964, 0.35209224, 0.09299817, 0.7106489)
bones/22/position = Vector3(0.038696717, 5.0118687e-11, 9.9849684e-11)
bones/22/rotation = Quaternion(0.0021266919, -0.004949208, 0.064930424, 0.9978753)
bones/23/position = Vector3(0.040621713, 1.0721979e-11, -5.127232e-12)
bones/24/position = Vector3(0.14, 1.110223e-16, 2.220446e-16)
bones/24/rotation = Quaternion(-2.7755576e-17, -6.938894e-17, -6.938894e-18, 1)
bones/25/position = Vector3(0.005, -2.7755576e-17, 0)
bones/25/rotation = Quaternion(-9.540979e-18, -2.7755576e-17, 9.540979e-18, 1)
bones/26/rotation = Quaternion(0.7842187, -0.19943702, -0.5848191, 0.056679882)
bones/27/rotation = Quaternion(0.052973837, 0.44702604, -0.029942662, 0.8924489)
bones/28/rotation = Quaternion(0.06465698, 0.12901439, -0.19377781, 0.97037363)
bones/29/position = Vector3(-0.26975244, 2.563412e-07, -1.1905385e-08)
bones/29/rotation = Quaternion(-0.4454563, -0.012538448, -0.12649484, 0.8862339)
bones/30/rotation = Quaternion(0.09673716, 0.06657806, 0.37996292, 0.91751707)
bones/31/rotation = Quaternion(-0.017224751, 0.24962947, 0.49292365, 0.8333155)
bones/33/rotation = Quaternion(-0.026649816, 0.050389662, 0.4562443, 0.888027)
bones/34/rotation = Quaternion(-0.0493639, 0.13757928, 0.58074373, 0.80085707)
bones/36/rotation = Quaternion(-0.14342895, 0.025572311, 0.42342505, 0.89413947)
bones/37/rotation = Quaternion(0.050029494, -0.01992205, 0.69104576, 0.7208023)
bones/39/rotation = Quaternion(-0.115030825, 0.01676327, 0.45154506, 0.88464344)
bones/40/rotation = Quaternion(0.020354148, 0.009153387, 0.6477204, 0.76155126)
bones/42/rotation = Quaternion(0.6151735, 0.28622907, 0.016048126, 0.7344229)
bones/43/rotation = Quaternion(0.19211918, 0.11141997, 0.124592975, 0.9670328)
bones/45/rotation = Quaternion(-0.1176271, 1.3974802e-16, -6.288661e-17, 0.99305785)
bones/46/rotation = Quaternion(-0.17323487, -2.099698e-25, 1.9374898e-17, 0.9848805)
bones/47/rotation = Quaternion(-0.0043949056, 0.010375962, -0.20370215, 0.97896814)
bones/48/position = Vector3(0.092836134, 0.0036415688, 2.7747754e-17)
bones/48/rotation = Quaternion(1.2661336e-17, 9.989056e-18, 0.13354194, 0.99104315)
bones/49/rotation = Quaternion(0.13130783, -0.05036935, 0.24724077, 0.95869356)
bones/50/position = Vector3(-0.42572036, 1.7074263e-12, -4.667877e-12)
bones/50/rotation = Quaternion(-0.048483394, -0.038352683, -0.5716499, 0.81816554)
bones/51/position = Vector3(-0.20476776, -1.3877788e-17, 0)
bones/52/position = Vector3(-0.4019669, -3.933849e-11, 1.899425e-12)
bones/52/rotation = Quaternion(-0.00021856392, -0.0061088647, 0.036131103, 0.9993284)
bones/54/position = Vector3(-0.22094238, 4.7704896e-18, 0)
bones/55/rotation = Quaternion(-0.041710682, 0.15009321, 0.97912854, -0.13053581)
bones/56/rotation = Quaternion(-0.11438767, 0.007083657, -0.2708839, 0.95576525)
bones/57/position = Vector3(0.20476907, 0, -5.551115e-17)
bones/58/rotation = Quaternion(-0.00023867, -0.056162532, 0.13990264, 0.98857117)
bones/60/position = Vector3(0.22094241, 3.035766e-18, -2.7755576e-17)
bones/67/position = Vector3(-4.440892e-16, 0, 7.632783e-17)
bones/67/rotation = Quaternion(-2.8449465e-16, 8.326673e-17, 2.7755576e-17, 1)
[node name="AnimationPlayer" parent="." index="1" unique_id=233699491]
libraries/custom = SubResource("AnimationLibrary_3r4wv")

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,6 @@
[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"]
[ext_resource type="PackedScene" uid="uid://mvh2v6v72stt" path="res://core/ai/agents/human/ai_human.tscn" id="2_n3ssi"]
[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)
@@ -41,12 +41,6 @@ mesh = SubResource("BoxMesh_lmjyn")
[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)
[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")
@@ -90,3 +84,9 @@ Parameters:
- Wait Time: Delay in seconds on the IdleState node.
- Area Radius: Radius of the SphereShape3D used by PatrolRadiusShape."
autowrap_mode = 2
[node name="AiBase" parent="." unique_id=1166354984 instance=ExtResource("2_n3ssi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.30116, 0.94226456, 6.322365)
[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, -17.32454, 16.344711, 0)