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")