matador animationingng

This commit is contained in:
2026-06-07 16:47:18 +03:00
parent f0d932eac3
commit 49a9bced4b
3 changed files with 22 additions and 21 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://matador_scene_v1"]
[ext_resource type="Script" path="res://matador.gd" id="1_matgd"]
[ext_resource type="PackedScene" uid="uid://qix7axtc0lf3" path="res://Blender/matador_v02.fbx" id="2_matfbx"]
[ext_resource type="PackedScene" uid="uid://ch5fiscgxfmpc" path="res://Blender/matador.glb" id="2_matfbx"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
radius = 0.25
@@ -26,4 +26,4 @@ monitorable = false
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
shape = SubResource("CapsuleShape3D_hit")
[node name="matador_v02" parent="." instance=ExtResource("2_matfbx")]
[node name="matador2" parent="." instance=ExtResource("2_matfbx")]
+2 -2
View File
@@ -92,14 +92,14 @@ func _register_all() -> void:
_reg_f("Camera", "cam_max_vert_angle", 45.0, 0.0, 90.0, 1.0)
# ── Matador ───────────────────────────────────────────────────────────────
_reg_f("Matador", "mat_spawn_count", 1.0, 1.0, 30.0, 1.0)
_reg_f("Matador", "mat_walk_speed", 2.5, 0.5, 10.0)
_reg_f("Matador", "mat_walk_speed", 4.0, 0.5, 10.0)
_reg_f("Matador", "mat_wander_radius", 22.0, 5.0, 50.0)
_reg_f("Matador", "mat_idle_min", 0.5, 0.0, 5.0, 0.1)
_reg_f("Matador", "mat_idle_max", 2.5, 0.5, 10.0, 0.1)
_reg_f("Matador", "mat_hit_threshold", 4.0, 1.0, 30.0)
_reg_f("Matador", "mat_ragdoll_impulse", 6.0, 0.5, 20.0)
_reg_f("Matador", "mat_flee_range", 3.5, 2.0, 40.0)
_reg_f("Matador", "mat_flee_speed", 2.5, 0.5, 12.0)
_reg_f("Matador", "mat_flee_speed", 5.5, 0.5, 12.0)
_reg_f("Matador", "mat_charge_speed", 10.0, 1.0, 30.0)
_reg_f("Matador", "mat_brace_range", 5.0, 2.0, 20.0)
_reg_f("Matador", "mat_brace_duration", 0.7, 0.05, 1.5, 0.05)
+17 -16
View File
@@ -25,12 +25,14 @@ var _ole_player: AudioStreamPlayer = null
var _death_player: AudioStreamPlayer = null
var _blood_burst: CPUParticles3D = null
@onready var _mesh: Node3D = $matador_v02
@onready var _mesh: Node3D = $matador2
@onready var _hit_area: Area3D = $HitArea
@onready var _body_col: CollisionShape3D = $CollisionShape3D
const _WALK_ANIM: StringName = &"Armature|walk"
const _IDLE_ANIM: StringName = &"Armature|idle"
const _ANIM_RUN: StringName = &"Run"
const _ANIM_IDLE: StringName = &"Taunt"
const _ANIM_ATTACK: StringName = &"Attack"
const _ANIM_ROLL: StringName = &"Roll"
func _ready() -> void:
@@ -40,12 +42,12 @@ func _ready() -> void:
if _skeleton:
_sim = _setup_physical_bones()
if _anim_player:
_ensure_loop(_WALK_ANIM)
if _anim_player.has_animation(_IDLE_ANIM):
_anim_player.play(_IDLE_ANIM)
else:
push_warning("Matador: idle animation not found. Available: %s" %
for anim in [_ANIM_RUN, _ANIM_IDLE, _ANIM_ATTACK, _ANIM_ROLL]:
_ensure_loop(anim)
if not _anim_player.has_animation(_ANIM_RUN):
push_warning("Matador: expected animations not found. Available: %s" %
str(_anim_player.get_animation_list()))
_anim_player.play(_ANIM_IDLE)
_hit_area.body_entered.connect(_on_body_entered)
_pick_wander_target()
_setup_blood_burst()
@@ -118,7 +120,7 @@ func _tick_wander(delta: float) -> void:
_idle_timer -= delta
velocity.x = move_toward(velocity.x, 0.0, 10.0 * delta)
velocity.z = move_toward(velocity.z, 0.0, 10.0 * delta)
_play_anim(_IDLE_ANIM)
_play_anim(_ANIM_IDLE)
move_and_slide()
return
@@ -134,7 +136,7 @@ func _tick_wander(delta: float) -> void:
velocity.z = dir.z * spd
_mesh.rotation.y = lerp_angle(
_mesh.rotation.y, atan2(velocity.x, velocity.z), delta * 8.0)
_play_anim(_WALK_ANIM)
_play_anim(_ANIM_RUN)
move_and_slide()
@@ -148,7 +150,7 @@ func _tick_flee(delta: float) -> void:
velocity.x = away.x * spd
velocity.z = away.z * spd
_mesh.rotation.y = lerp_angle(_mesh.rotation.y, atan2(velocity.x, velocity.z), delta * 8.0)
_play_anim(_WALK_ANIM)
_play_anim(_ANIM_RUN)
move_and_slide()
@@ -181,7 +183,7 @@ func _tick_brace(delta: float) -> void:
if to_bull.length() > 0.1:
_mesh.rotation.y = lerp_angle(
_mesh.rotation.y, atan2(to_bull.x, to_bull.z), delta * 14.0)
_play_anim(_IDLE_ANIM)
_play_anim(_ANIM_ATTACK)
move_and_slide()
_brace_timer -= delta
@@ -212,7 +214,7 @@ func _tick_sidestep(delta: float) -> void:
velocity.z = _step_dir.z * spd
# Snap facing quickly to sell the movement
_mesh.rotation.y = lerp_angle(_mesh.rotation.y, atan2(velocity.x, velocity.z), delta * 20.0)
_play_anim(_WALK_ANIM)
_play_anim(_ANIM_ROLL)
move_and_slide()
@@ -375,11 +377,10 @@ func _ensure_loop(anim_name: StringName) -> void:
func _play_anim(anim_name: StringName) -> void:
if not _anim_player:
if _anim_player == null:
return
if not _anim_player.has_animation(anim_name):
if _anim_player.current_animation == anim_name:
return
if _anim_player.current_animation != anim_name:
_anim_player.play(anim_name)