Commit c35090ea authored by Gavin An's avatar Gavin An

작업중

parent 4461930d
......@@ -3,9 +3,9 @@
[ext_resource type="MeshLibrary" uid="uid://ddc7y16q0whgv" path="res://src/map/tile_mesh_library.tres" id="1_nxx65"]
[ext_resource type="Script" uid="uid://dd1xgi6hnpuvs" path="res://src/core/rts_camera.gd" id="1_rts_cam"]
[ext_resource type="Script" uid="uid://cq7r51whh6po" path="res://src/core/stage_manager.gd" id="2_stage_mgr"]
[ext_resource type="PackedScene" uid="uid://dimlohck6ebg7" path="res://src/entities/monsters/noble_man/noble_man_unit.tscn" id="3_base_monster"]
[ext_resource type="PackedScene" uid="uid://dimlohck6ebg7" path="res://src/entities/monsters/noble_man/noble_man_monster.tscn" id="4_nxx65"]
[ext_resource type="Script" uid="uid://dkplkt6q8e3b5" path="res://src/core/unit_controller.gd" id="4_unit_ctrl"]
[ext_resource type="PackedScene" uid="uid://dfsvswt2g4422" path="res://src/entities/monsters/zombie/zombie_unit.tscn" id="5_2uitn"]
[ext_resource type="PackedScene" uid="uid://dfsvswt2g4422" path="res://src/entities/monsters/zombie/zombie_monster.tscn" id="5_2uitn"]
[ext_resource type="PackedScene" uid="uid://bqga1rvcjyydy" path="res://src/ui/hud.tscn" id="5_hud"]
[sub_resource type="NavigationMesh" id="NavigationMesh_map"]
......@@ -45,7 +45,7 @@ script = ExtResource("1_rts_cam")
[node name="StageManager" type="Node" parent="." unique_id=132524356]
script = ExtResource("2_stage_mgr")
monster_scenes = Array[PackedScene]([ExtResource("3_base_monster"), ExtResource("5_2uitn")])
monster_scenes = Array[PackedScene]([ExtResource("4_nxx65"), ExtResource("5_2uitn")])
[node name="UnitController" type="Control" parent="." unique_id=552898295]
layout_mode = 3
......
[gd_scene format=3 uid="uid://dimlohck6ebg7"]
[ext_resource type="Script" path="res://src/entities/monsters/noble_man/noble_man_monster.gd" id="1_base_monster"]
[ext_resource type="Script" uid="uid://dk2xux8f0hp7m" path="res://src/entities/monsters/noble_man/noble_man_monster.gd" id="1_base_monster"]
[ext_resource type="PackedScene" uid="uid://dy3qfnuybgjg6" path="res://src/entities/monsters/noble_man/noble_man.tscn" id="2_noble_man"]
[sub_resource type="SphereShape3D" id="SphereShape3D_collision"]
......@@ -13,77 +13,51 @@ script = ExtResource("1_base_monster")
transform = Transform3D(-1, 0, 1.509958e-07, 0, 1, 0, -1.509958e-07, 0, -1, 0, 0, 0)
[node name="Skeleton3D" parent="noble_man/Armature" parent_id_path=PackedInt32Array(174344433, 789802200) index="0" unique_id=1272502782]
bones/0/position = Vector3(-0.0020419173, -0.058207292, 1.0586033)
bones/0/rotation = Quaternion(0.70190245, 0.011034894, 0.00014947543, 0.71218765)
bones/0/scale = Vector3(0.99999994, 1, 0.99999994)
bones/1/position = Vector3(0.10183821, -0.10193097, -0.0022784735)
bones/1/rotation = Quaternion(0.9622586, 0.06553567, -0.15610032, 0.21306369)
bones/1/scale = Vector3(1.0000077, 1, 1)
bones/2/position = Vector3(8.925652e-09, 0.417691, -5.1505884e-09)
bones/2/rotation = Quaternion(0.5536645, 0.116959944, 0.057919815, 0.8224484)
bones/2/scale = Vector3(1.0000001, 1.0000004, 1.0000002)
bones/3/position = Vector3(-2.5261881e-09, 0.42174494, 7.2241504e-11)
bones/3/rotation = Quaternion(-0.45563436, -0.06292275, -0.016682481, 0.8877837)
bones/3/scale = Vector3(1, 1, 1)
bones/4/position = Vector3(1.2221635e-08, 0.13995555, 2.1287123e-08)
bones/4/rotation = Quaternion(-0.37498686, 0.01245499, -0.019623883, 0.9267388)
bones/4/scale = Vector3(0.9999998, 1, 0.9999998)
bones/5/position = Vector3(-0.099749625, -0.1055433, -0.00022072843)
bones/5/rotation = Quaternion(0.9903288, -0.0092331655, 0.10971114, 0.084422834)
bones/5/scale = Vector3(1.000016, 0.99999976, 1.0000005)
bones/6/position = Vector3(-2.6841812e-08, 0.4172189, 1.4898632e-08)
bones/6/rotation = Quaternion(0.24538626, -0.08616291, -0.0015821799, 0.9655875)
bones/6/scale = Vector3(1.0000001, 1, 1.0000001)
bones/7/position = Vector3(-1.1679395e-08, 0.41914502, -1.1094577e-07)
bones/7/rotation = Quaternion(-0.46878454, 0.09844392, 0.044253245, 0.87669355)
bones/7/scale = Vector3(1, 1.0000001, 1)
bones/8/position = Vector3(5.047954e-10, 0.12296724, -2.2279302e-08)
bones/8/rotation = Quaternion(-0.39594132, 0.028365131, 0.040902868, 0.9169257)
bones/8/scale = Vector3(0.9999999, 0.9999999, 0.9999999)
bones/9/position = Vector3(-0.0020885684, 0.116008654, 0.0024992328)
bones/9/rotation = Quaternion(0.043750413, -0.0020669356, 0.00819689, 0.9990068)
bones/9/scale = Vector3(0.99999994, 0.9999998, 0.99999976)
bones/10/position = Vector3(-2.2647062e-09, 0.11605439, -9.138862e-09)
bones/10/rotation = Quaternion(0.018322818, -0.022007098, 0.0087936465, 0.99955124)
bones/10/scale = Vector3(1.0000001, 1.0000002, 1.0000002)
bones/11/position = Vector3(5.6057953e-16, 0.11605399, -1.8735637e-09)
bones/11/rotation = Quaternion(-0.07043908, -0.026146572, 0.008986988, 0.99713284)
bones/11/scale = Vector3(0.9999999, 1, 1)
bones/12/position = Vector3(0.042316522, 0.018807229, -0.0012655992)
bones/12/rotation = Quaternion(0.6535891, 0.46662202, -0.47374266, 0.3614596)
bones/12/scale = Vector3(1.0000001, 1.0000001, 1.0000002)
bones/13/position = Vector3(1.2083032e-07, 0.1687637, -1.5166692e-07)
bones/13/rotation = Quaternion(0.26553997, 0.6469928, 0.20580651, 0.6844944)
bones/13/scale = Vector3(1.0000001, 1.0000001, 1)
bones/14/position = Vector3(7.0695954e-08, 0.28124455, -4.496629e-08)
bones/14/rotation = Quaternion(-0.11034532, -0.037103236, 0.011850772, 0.99312985)
bones/14/scale = Vector3(0.99999994, 1, 1)
bones/15/position = Vector3(5.1876157e-08, 0.2978702, 1.1475281e-07)
bones/15/rotation = Quaternion(0.19980764, 0.12052846, 0.13753434, 0.96261835)
bones/15/scale = Vector3(1, 0.99999994, 0.99999994)
bones/16/position = Vector3(-0.042962536, 0.012112379, -0.0065097106)
bones/16/rotation = Quaternion(-0.62357396, 0.49894008, -0.49325305, -0.34484175)
bones/16/scale = Vector3(0.9999999, 1, 1)
bones/17/position = Vector3(-1.3961997e-07, 0.17218974, -1.2206406e-06)
bones/17/rotation = Quaternion(0.17426653, -0.6359149, -0.20773616, 0.7225573)
bones/17/scale = Vector3(1.0000001, 1, 1.0000002)
bones/18/position = Vector3(4.2020838e-07, 0.26897195, 9.862248e-08)
bones/18/rotation = Quaternion(-0.21958746, 0.040991135, -0.06345784, 0.97266346)
bones/18/scale = Vector3(0.99999994, 1, 1)
bones/19/position = Vector3(-8.227692e-08, 0.2969355, 4.939664e-09)
bones/19/rotation = Quaternion(0.17809258, -0.121117584, -0.13766451, 0.9667792)
bones/19/scale = Vector3(0.99999994, 0.9999998, 0.9999998)
bones/20/position = Vector3(0.00064602116, 0.07547628, 0.007775514)
bones/20/rotation = Quaternion(0.044769283, 0.022577364, -0.0023045582, 0.99873954)
bones/20/scale = Vector3(1, 1, 0.9999998)
bones/21/position = Vector3(-2.7577591e-09, 0.07526942, -1.1876011e-07)
bones/21/rotation = Quaternion(0.22196482, 0.037162263, -0.020780204, 0.9741246)
bones/21/scale = Vector3(1, 1.0000001, 1.0000002)
bones/22/position = Vector3(-3.6878883e-10, 0.30715173, -0.13331519)
bones/22/rotation = Quaternion(-0.21240355, 0.00014905656, 0.00010942089, 0.9771821)
bones/22/scale = Vector3(1, 1.0000001, 1)
bones/23/position = Vector3(3.687908e-10, 0.06441903, 0.13331476)
bones/23/rotation = Quaternion(0.53147167, -6.369973e-08, -3.7991345e-08, 0.8470761)
bones/23/scale = Vector3(1, 1, 1.0000001)
[node name="MonsterArea" type="Area3D" parent="." unique_id=2000374352]
......
......@@ -48,45 +48,8 @@ func _ready() -> void:
if unit_data:
_apply_unit_style()
# 자식 노드 중 3D 모델(striker, guardian 등) 노드 자동 탐색 및 초기화
var model_names: Array[String] = ["striker", "guardian", "ranger"]
var detected_model_node: Node3D = null
var detected_model_name: String = ""
for m_name: String in model_names:
var node: Node3D = get_node_or_null(m_name) as Node3D
if node:
detected_model_node = node
detected_model_name = m_name
break
if detected_model_node:
_model_instance = detected_model_node
if detected_model_name == "striker":
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/striker_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
elif detected_model_name == "guardian":
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/guardian/guardian_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
elif detected_model_name == "ranger":
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/ranger/ranger_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
_model_anim_player = UnitHelper.find_animation_player(_model_instance)
if _model_anim_player:
print("BaseUnit: Linked pre-configured model & AnimationPlayer: ", detected_model_name)
# 모델명_animations.tres 라이브러리를 동적으로 로드하여 등록
var anim_lib_path: String = "res://assets/models/units/" + detected_model_name + "/" + detected_model_name + "_animations.tres"
if ResourceLoader.exists(anim_lib_path):
var lib: AnimationLibrary = load(anim_lib_path) as AnimationLibrary
if lib:
if _model_anim_player.has_animation_library(""):
_model_anim_player.remove_animation_library("")
_model_anim_player.add_animation_library(detected_model_name, lib)
print("BaseUnit: Loaded and registered ", detected_model_name, " animations library successfully.")
UnitHelper.clean_root_animation_tracks(_model_anim_player)
# 자식 클래스에서 모델, 무기, 애니메이션 관련 비주얼 초기화 수행
_setup_unit_visuals()
......@@ -278,29 +241,17 @@ func _try_attack() -> void:
# 데미지 적용 및 발사체 발사 처리 분기
if unit_data.is_ranged:
# 원거리 유닛: 유도 발사체(Projectile) 생성하여 발사
var projectile_script = preload("res://src/entities/units/projectile.gd")
var proj: Node3D = projectile_script.new() as Node3D
proj.set("damage", unit_data.damage)
proj.set("target", _target_monster)
proj.set("color", unit_data.unit_color)
# Ranger: arrow.glb 모델 화살 사용
var model_name: String = _model_instance.name.to_lower() if _model_instance else ""
if model_name == "ranger":
proj.set("use_arrow_model", true)
# 발사 위치: Ranger는 활이 장착된 LeftHand 본 위치에서, 나머지는 어깨 높이
# 원거리 유닛: 발사 위치 계산 후 가상 함수 호출하여 생성 위임
var fire_position: Vector3 = global_position + Vector3(0.0, 0.7, 0.0)
var model_name: String = _model_instance.name.to_lower() if _model_instance else ""
if model_name == "ranger" and _model_instance:
var bow_attachment: BoneAttachment3D = UnitHelper.get_bone_attachment(
_model_instance, "LeftHandAttachment"
)
if bow_attachment:
fire_position = bow_attachment.global_position
proj.global_position = fire_position
get_tree().current_scene.add_child(proj)
_spawn_projectile(fire_position)
else:
# 근접 유닛: 공격 애니메이션 중간 즈음(락아웃 시간의 50% 지점)에 데미지 지연 적용
var target_ref: Node3D = _target_monster
......@@ -372,62 +323,14 @@ func deselect() -> void:
_selection_ring.visible = false
## 상태(대기, 이동, 공격)별 3D 애니메이션 트랙 제어 및 크로스페이드 블렌딩
## 상태(대기, 이동, 공격)별 3D 애니메이션 트랙 제어 (상속 클래스에서 재정의)
func _update_animations() -> void:
if not _model_anim_player:
return
var model_name: String = ""
if _model_instance:
model_name = _model_instance.name.to_lower()
var library_prefix: String = model_name + "/"
var has_custom_anims: bool = _model_anim_player.has_animation(library_prefix + "Idle")
var target_anim: String = ""
var play_speed: float = 1.0
var blend_time: float = 0.2 # 뚝뚝 끊기는 현상을 없애기 위한 0.2초 부드러운 크로스페이드
if has_custom_anims:
var attack_key: String = "Draw" if model_name == "ranger" else "Slash"
var attack_anim: String = library_prefix + attack_key
var run_anim: String = library_prefix + "Running"
var idle_anim: String = library_prefix + "Idle"
# 1. 공격 락이 활성화되어 있는 동안에는 공격 애니메이션 강제 재생
if _attack_lock_timer > 0.0:
var base_speed: float = 1.5
if unit_data.cooldown < 0.6:
base_speed = 0.6 / unit_data.cooldown
play_speed = clampf(base_speed, 1.0, 3.0)
target_anim = attack_anim
# 2. 이동 중 상태: 속도가 있을 때
elif velocity.length() > 0.1:
target_anim = run_anim
play_speed = 1.2
# 3. 대기 상태: 정지 상태 및 쿨다운 중 대기할 때
else:
target_anim = idle_anim
play_speed = 1.0
# 애니메이션 전환 및 크로스페이드 블렌딩 실행
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_last_anim_state = target_anim.replace(library_prefix, "")
_model_anim_player.play(target_anim, blend_time, play_speed)
else:
# Fallback: 기존 캡슐 Jump 애니메이션 처리
var fallback_anim: String = "Armature|Armature|Basic_Jump|baselayer"
if not _model_anim_player.has_animation(fallback_anim):
return
if _attack_lock_timer > 0.0:
target_anim = fallback_anim
play_speed = 2.5
elif velocity.length() > 0.1:
target_anim = fallback_anim
play_speed = 1.5
else:
target_anim = ""
_model_anim_player.stop()
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_model_anim_player.play(target_anim, blend_time, play_speed)
pass
## 자식 클래스에서 모델, 무기, 애니메이션 관련 비주얼을 초기화하는 가상 함수
func _setup_unit_visuals() -> void:
pass
## 원거리 유닛의 발사체 생성을 처리하는 가상 함수
func _spawn_projectile(_fire_position: Vector3) -> void:
pass
class_name GuardianUnit
extends BaseUnit
## Guardian 유닛 고유 동작 및 비주얼 제어 클래스
func _setup_unit_visuals() -> void:
# 자식 노드 중 가디언 모델 노드 명시적 확보
var m_name: String = "guardian"
var node: Node3D = get_node_or_null(m_name) as Node3D
if not node:
push_error("GuardianUnit: Model node '" + m_name + "' not found under children.")
return
_model_instance = node
# 가디언 스킨 및 무기 결합
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/guardian/guardian_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
# 애니메이션 플레이어 및 라이브러리 연동
_model_anim_player = UnitHelper.find_animation_player(_model_instance)
if _model_anim_player:
print("GuardianUnit: Linked pre-configured model & AnimationPlayer: ", m_name)
var anim_lib_path: String = "res://assets/models/units/" + m_name + "/" + m_name + "_animations.tres"
if ResourceLoader.exists(anim_lib_path):
var lib: AnimationLibrary = load(anim_lib_path) as AnimationLibrary
if lib:
if _model_anim_player.has_animation_library(""):
_model_anim_player.remove_animation_library("")
if not _model_anim_player.has_animation_library(m_name):
_model_anim_player.add_animation_library(m_name, lib)
print("GuardianUnit: Loaded and registered ", m_name, " animations library successfully.")
UnitHelper.clean_root_animation_tracks(_model_anim_player)
## 가디언 애니메이션 갱신 제어
func _update_animations() -> void:
if not _model_anim_player:
return
var m_name: String = "guardian"
var library_prefix: String = m_name + "/"
var has_custom_anims: bool = _model_anim_player.has_animation(library_prefix + "Idle")
var target_anim: String = ""
var play_speed: float = 1.0
var blend_time: float = 0.2
if has_custom_anims:
var attack_anim: String = library_prefix + "Slash"
var run_anim: String = library_prefix + "Running"
var idle_anim: String = library_prefix + "Idle"
if _attack_lock_timer > 0.0:
var base_speed: float = 1.5
if unit_data.cooldown < 0.6:
base_speed = 0.6 / unit_data.cooldown
play_speed = clampf(base_speed, 1.0, 3.0)
target_anim = attack_anim
elif velocity.length() > 0.1:
target_anim = run_anim
play_speed = 1.2
else:
target_anim = idle_anim
play_speed = 1.0
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_last_anim_state = target_anim.replace(library_prefix, "")
_model_anim_player.play(target_anim, blend_time, play_speed)
else:
# Fallback 처리
var fallback_anim: String = "Armature|Armature|Basic_Jump|baselayer"
if not _model_anim_player.has_animation(fallback_anim):
return
if _attack_lock_timer > 0.0:
target_anim = fallback_anim
play_speed = 2.5
elif velocity.length() > 0.1:
target_anim = fallback_anim
play_speed = 1.5
else:
target_anim = ""
_model_anim_player.stop()
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_model_anim_player.play(target_anim, blend_time, play_speed)
[gd_scene format=3 uid="uid://cx4vbc5m3myqk"]
[ext_resource type="Script" uid="uid://daq4ko8ryry3w" path="res://src/entities/units/base_unit.gd" id="1_base_unit"]
[ext_resource type="Script" path="res://src/entities/units/guardian/guardian_unit.gd" id="1_base_unit"]
[ext_resource type="PackedScene" uid="uid://dh00osxx32ll" path="res://src/entities/units/guardian/guardian.tscn" id="2_y84tp"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
......
class_name RangerUnit
extends BaseUnit
## Ranger 유닛 고유 동작 및 비주얼 제어 클래스
func _setup_unit_visuals() -> void:
# 자식 노드 중 레인저 모델 노드 명시적 확보
var m_name: String = "ranger"
var node: Node3D = get_node_or_null(m_name) as Node3D
if not node:
push_error("RangerUnit: Model node '" + m_name + "' not found under children.")
return
_model_instance = node
# 레인저 스킨 및 무기 결합
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/ranger/ranger_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
# 애니메이션 플레이어 및 라이브러리 연동
_model_anim_player = UnitHelper.find_animation_player(_model_instance)
if _model_anim_player:
print("RangerUnit: Linked pre-configured model & AnimationPlayer: ", m_name)
var anim_lib_path: String = "res://assets/models/units/" + m_name + "/" + m_name + "_animations.tres"
if ResourceLoader.exists(anim_lib_path):
var lib: AnimationLibrary = load(anim_lib_path) as AnimationLibrary
if lib:
if _model_anim_player.has_animation_library(""):
_model_anim_player.remove_animation_library("")
if not _model_anim_player.has_animation_library(m_name):
_model_anim_player.add_animation_library(m_name, lib)
print("RangerUnit: Loaded and registered ", m_name, " animations library successfully.")
UnitHelper.clean_root_animation_tracks(_model_anim_player)
## 레인저 애니메이션 갱신 제어 (Draw 애니메이션 적용)
func _update_animations() -> void:
if not _model_anim_player:
return
var m_name: String = "ranger"
var library_prefix: String = m_name + "/"
var has_custom_anims: bool = _model_anim_player.has_animation(library_prefix + "Idle")
var target_anim: String = ""
var play_speed: float = 1.0
var blend_time: float = 0.2
if has_custom_anims:
var attack_anim: String = library_prefix + "Draw"
var run_anim: String = library_prefix + "Running"
var idle_anim: String = library_prefix + "Idle"
if _attack_lock_timer > 0.0:
var base_speed: float = 1.5
if unit_data.cooldown < 0.6:
base_speed = 0.6 / unit_data.cooldown
play_speed = clampf(base_speed, 1.0, 3.0)
target_anim = attack_anim
elif velocity.length() > 0.1:
target_anim = run_anim
play_speed = 1.2
else:
target_anim = idle_anim
play_speed = 1.0
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_last_anim_state = target_anim.replace(library_prefix, "")
_model_anim_player.play(target_anim, blend_time, play_speed)
else:
# Fallback 처리
var fallback_anim: String = "Armature|Armature|Basic_Jump|baselayer"
if not _model_anim_player.has_animation(fallback_anim):
return
if _attack_lock_timer > 0.0:
target_anim = fallback_anim
play_speed = 2.5
elif velocity.length() > 0.1:
target_anim = fallback_anim
play_speed = 1.5
else:
target_anim = ""
_model_anim_player.stop()
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_model_anim_player.play(target_anim, blend_time, play_speed)
## 레인저 전용 발사체 생성 및 스폰
func _spawn_projectile(fire_position: Vector3) -> void:
var projectile_script = preload("res://src/entities/units/projectile.gd")
var proj: Node3D = projectile_script.new() as Node3D
proj.set("damage", unit_data.damage)
proj.set("target", _target_monster)
proj.set("color", unit_data.unit_color)
proj.set("use_arrow_model", true)
get_tree().current_scene.add_child(proj)
proj.global_position = fire_position
[gd_scene format=3 uid="uid://qdvm4bgh48q6"]
[ext_resource type="Script" uid="uid://daq4ko8ryry3w" path="res://src/entities/units/base_unit.gd" id="1_base_unit"]
[ext_resource type="Script" path="res://src/entities/units/ranger/ranger_unit.gd" id="1_base_unit"]
[ext_resource type="PackedScene" path="res://src/entities/units/ranger/ranger.tscn" id="2_ranger_scene"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
......
class_name StrikerUnit
extends BaseUnit
## Striker 유닛 고유 동작 및 비주얼 제어 클래스
func _setup_unit_visuals() -> void:
# 자식 노드 중 스트라이커 모델 노드 명시적 확보
var m_name: String = "striker"
var node: Node3D = get_node_or_null(m_name) as Node3D
if not node:
push_error("StrikerUnit: Model node '" + m_name + "' not found under children.")
return
_model_instance = node
# 스트라이커 스킨 및 무기 결합 (원래 striker 스킨 경로는 units/striker_0.png 이었음)
UnitHelper.apply_skin(_model_instance, "res://assets/models/units/striker_0.png")
UnitHelper.attach_weapon(_model_instance, unit_data)
# 애니메이션 플레이어 및 라이브러리 연동
_model_anim_player = UnitHelper.find_animation_player(_model_instance)
if _model_anim_player:
print("StrikerUnit: Linked pre-configured model & AnimationPlayer: ", m_name)
var anim_lib_path: String = "res://assets/models/units/" + m_name + "/" + m_name + "_animations.tres"
if ResourceLoader.exists(anim_lib_path):
var lib: AnimationLibrary = load(anim_lib_path) as AnimationLibrary
if lib:
if _model_anim_player.has_animation_library(""):
_model_anim_player.remove_animation_library("")
if not _model_anim_player.has_animation_library(m_name):
_model_anim_player.add_animation_library(m_name, lib)
print("StrikerUnit: Loaded and registered ", m_name, " animations library successfully.")
UnitHelper.clean_root_animation_tracks(_model_anim_player)
## 스트라이커 애니메이션 갱신 제어
func _update_animations() -> void:
if not _model_anim_player:
return
var m_name: String = "striker"
var library_prefix: String = m_name + "/"
var has_custom_anims: bool = _model_anim_player.has_animation(library_prefix + "Idle")
var target_anim: String = ""
var play_speed: float = 1.0
var blend_time: float = 0.2
if has_custom_anims:
var attack_anim: String = library_prefix + "Slash"
var run_anim: String = library_prefix + "Running"
var idle_anim: String = library_prefix + "Idle"
if _attack_lock_timer > 0.0:
var base_speed: float = 1.5
if unit_data.cooldown < 0.6:
base_speed = 0.6 / unit_data.cooldown
play_speed = clampf(base_speed, 1.0, 3.0)
target_anim = attack_anim
elif velocity.length() > 0.1:
target_anim = run_anim
play_speed = 1.2
else:
target_anim = idle_anim
play_speed = 1.0
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_last_anim_state = target_anim.replace(library_prefix, "")
_model_anim_player.play(target_anim, blend_time, play_speed)
else:
# Fallback 처리
var fallback_anim: String = "Armature|Armature|Basic_Jump|baselayer"
if not _model_anim_player.has_animation(fallback_anim):
return
if _attack_lock_timer > 0.0:
target_anim = fallback_anim
play_speed = 2.5
elif velocity.length() > 0.1:
target_anim = fallback_anim
play_speed = 1.5
else:
target_anim = ""
_model_anim_player.stop()
if target_anim != "" and _model_anim_player.current_animation != target_anim:
_model_anim_player.play(target_anim, blend_time, play_speed)
[gd_scene format=3 uid="uid://dwvbc5m3myqbk"]
[ext_resource type="Script" uid="uid://daq4ko8ryry3w" path="res://src/entities/units/base_unit.gd" id="1_base_unit"]
[ext_resource type="Script" path="res://src/entities/units/striker/striker_unit.gd" id="1_base_unit"]
[ext_resource type="PackedScene" uid="uid://c2aiejcidlihv" path="res://src/entities/units/striker/striker.tscn" id="2_iytoq"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment