feat: 보스 점프 스킬 - 타겟 위치로 이동 구현
- SkillData에 jumpToTarget, animationSpeed 필드 추가 - 점프 중 XZ를 타겟 위치로 lerp, 착지 시 스냅 - endClip 재생 중 점프 이동 비활성화 (IsInEndAnimation) - 보스/플레이어 겹침 시 플레이어를 밀어내는 방식으로 분리 처리 - 점프준비/점프/착지 3단계 스킬 & 패턴 구성 - UsePatternAction에 Target 블랙보드 변수 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1155,7 +1155,7 @@ MonoBehaviour:
|
|||||||
PlayerPrefab: {fileID: 6473031571298860035, guid: 9f538e60b8b98634b8952310b91dfba0, type: 3}
|
PlayerPrefab: {fileID: 6473031571298860035, guid: 9f538e60b8b98634b8952310b91dfba0, type: 3}
|
||||||
Prefabs:
|
Prefabs:
|
||||||
NetworkPrefabsLists:
|
NetworkPrefabsLists:
|
||||||
- {fileID: 11400000, guid: 1124711eebe5b22409c64043c7d96691, type: 2}
|
- {fileID: 11400000, guid: 456770a930389f64aa321439ffc4bdb2, type: 2}
|
||||||
TickRate: 30
|
TickRate: 30
|
||||||
ClientConnectionBufferTimeout: 10
|
ClientConnectionBufferTimeout: 10
|
||||||
ConnectionApproval: 0
|
ConnectionApproval: 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -381,6 +381,100 @@ ModelImporter:
|
|||||||
maskType: 1
|
maskType: 1
|
||||||
maskSource: {fileID: 31900000, guid: e8e1ad9aea8c740458a8550aa77c27b0, type: 2}
|
maskSource: {fileID: 31900000, guid: e8e1ad9aea8c740458a8550aa77c27b0, type: 2}
|
||||||
additiveReferencePoseFrame: 1
|
additiveReferencePoseFrame: 1
|
||||||
|
- serializedVersion: 16
|
||||||
|
name: "AnimClip_\uC810\uD504 \uC900\uBE44"
|
||||||
|
takeName: A_MOD_GBL_Jump_Idle_RM_Neut
|
||||||
|
internalID: -5764696784021583549
|
||||||
|
firstFrame: 1
|
||||||
|
lastFrame: 21
|
||||||
|
wrapMode: 0
|
||||||
|
orientationOffsetY: 0
|
||||||
|
level: 0
|
||||||
|
cycleOffset: 0
|
||||||
|
loop: 0
|
||||||
|
hasAdditiveReferencePose: 0
|
||||||
|
loopTime: 0
|
||||||
|
loopBlend: 0
|
||||||
|
loopBlendOrientation: 0
|
||||||
|
loopBlendPositionY: 0
|
||||||
|
loopBlendPositionXZ: 0
|
||||||
|
keepOriginalOrientation: 0
|
||||||
|
keepOriginalPositionY: 1
|
||||||
|
keepOriginalPositionXZ: 0
|
||||||
|
heightFromFeet: 0
|
||||||
|
mirror: 0
|
||||||
|
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||||
|
curves: []
|
||||||
|
events: []
|
||||||
|
transformMask: []
|
||||||
|
maskType: 3
|
||||||
|
maskSource: {fileID: 31900000, guid: e8e1ad9aea8c740458a8550aa77c27b0, type: 2}
|
||||||
|
additiveReferencePoseFrame: 1
|
||||||
|
- serializedVersion: 16
|
||||||
|
name: "AnimClip_\uC810\uD504 \uC911"
|
||||||
|
takeName: A_MOD_GBL_Jump_Idle_RM_Neut
|
||||||
|
internalID: 5443862797743907653
|
||||||
|
firstFrame: 22
|
||||||
|
lastFrame: 43
|
||||||
|
wrapMode: 0
|
||||||
|
orientationOffsetY: 0
|
||||||
|
level: 0
|
||||||
|
cycleOffset: 0
|
||||||
|
loop: 0
|
||||||
|
hasAdditiveReferencePose: 0
|
||||||
|
loopTime: 0
|
||||||
|
loopBlend: 0
|
||||||
|
loopBlendOrientation: 0
|
||||||
|
loopBlendPositionY: 0
|
||||||
|
loopBlendPositionXZ: 0
|
||||||
|
keepOriginalOrientation: 0
|
||||||
|
keepOriginalPositionY: 1
|
||||||
|
keepOriginalPositionXZ: 0
|
||||||
|
heightFromFeet: 0
|
||||||
|
mirror: 0
|
||||||
|
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||||
|
curves: []
|
||||||
|
events: []
|
||||||
|
transformMask: []
|
||||||
|
maskType: 3
|
||||||
|
maskSource: {fileID: 31900000, guid: e8e1ad9aea8c740458a8550aa77c27b0, type: 2}
|
||||||
|
additiveReferencePoseFrame: 1
|
||||||
|
- serializedVersion: 16
|
||||||
|
name: "AnimClip_\uC810\uD504 \uCC29\uC9C0"
|
||||||
|
takeName: A_MOD_GBL_Jump_Idle_RM_Neut
|
||||||
|
internalID: 4379034921508237129
|
||||||
|
firstFrame: 44
|
||||||
|
lastFrame: 79
|
||||||
|
wrapMode: 0
|
||||||
|
orientationOffsetY: 0
|
||||||
|
level: 0
|
||||||
|
cycleOffset: 0
|
||||||
|
loop: 0
|
||||||
|
hasAdditiveReferencePose: 0
|
||||||
|
loopTime: 0
|
||||||
|
loopBlend: 0
|
||||||
|
loopBlendOrientation: 0
|
||||||
|
loopBlendPositionY: 0
|
||||||
|
loopBlendPositionXZ: 0
|
||||||
|
keepOriginalOrientation: 0
|
||||||
|
keepOriginalPositionY: 1
|
||||||
|
keepOriginalPositionXZ: 0
|
||||||
|
heightFromFeet: 0
|
||||||
|
mirror: 0
|
||||||
|
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||||
|
curves: []
|
||||||
|
events:
|
||||||
|
- time: 0.052378073
|
||||||
|
functionName: OnEffect
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {instanceID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
transformMask: []
|
||||||
|
maskType: 3
|
||||||
|
maskSource: {fileID: 31900000, guid: e8e1ad9aea8c740458a8550aa77c27b0, type: 2}
|
||||||
|
additiveReferencePoseFrame: 1
|
||||||
isReadable: 0
|
isReadable: 0
|
||||||
meshes:
|
meshes:
|
||||||
lODScreenPercentages: []
|
lODScreenPercentages: []
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Colosseum.Game::Colosseum.AI.BossPatternData
|
m_EditorClassIdentifier: Colosseum.Game::Colosseum.AI.BossPatternData
|
||||||
patternName: "\uAE30\uBCF8 \uD328\uD134"
|
patternName: "\uAE30\uBCF8 \uD328\uD134"
|
||||||
steps:
|
steps:
|
||||||
|
- Type: 0
|
||||||
|
Skill: {fileID: 11400000, guid: 0e22d4b1dc395a04fb00ca4f82aeb838, type: 2}
|
||||||
|
Duration: 0
|
||||||
- Type: 0
|
- Type: 0
|
||||||
Skill: {fileID: 11400000, guid: 7556a61cbdcf2984684a762119e6e1b2, type: 2}
|
Skill: {fileID: 11400000, guid: 7556a61cbdcf2984684a762119e6e1b2, type: 2}
|
||||||
Duration: 0
|
Duration: 0
|
||||||
cooldown: 5
|
- Type: 0
|
||||||
|
Skill: {fileID: 11400000, guid: 16321efbd1f2498458683bac7605b054, type: 2}
|
||||||
|
Duration: 0
|
||||||
|
cooldown: 1
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ MonoBehaviour:
|
|||||||
skillName: "\uC810\uD504"
|
skillName: "\uC810\uD504"
|
||||||
description:
|
description:
|
||||||
icon: {fileID: 0}
|
icon: {fileID: 0}
|
||||||
skillClip: {fileID: -8752051743343580635, guid: 5eaeca917bbeb494eb14ad0e0552c42f, type: 3}
|
skillClip: {fileID: 5443862797743907653, guid: 5eaeca917bbeb494eb14ad0e0552c42f, type: 3}
|
||||||
endClip: {fileID: 0}
|
endClip: {fileID: 0}
|
||||||
|
animationSpeed: 1
|
||||||
useRootMotion: 1
|
useRootMotion: 1
|
||||||
ignoreRootMotionY: 0
|
ignoreRootMotionY: 0
|
||||||
|
jumpToTarget: 1
|
||||||
cooldown: 0
|
cooldown: 0
|
||||||
manaCost: 0
|
manaCost: 0
|
||||||
effects:
|
effects:
|
||||||
- {fileID: 11400000, guid: 11bd2d1ebdbfc2f4abf5a9d886615eb3, type: 2}
|
- {fileID: 0}
|
||||||
|
|||||||
27
Assets/_Game/Data/Skills/Data_Skill_TestBoss_점프준비.asset
Normal file
27
Assets/_Game/Data/Skills/Data_Skill_TestBoss_점프준비.asset
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 94f0a76cebcac2f4fb5daf1b675fd79f, type: 3}
|
||||||
|
m_Name: "Data_Skill_TestBoss_\uC810\uD504\uC900\uBE44"
|
||||||
|
m_EditorClassIdentifier: Colosseum.Game::Colosseum.Skills.SkillData
|
||||||
|
skillName: "\uC810\uD504"
|
||||||
|
description:
|
||||||
|
icon: {fileID: 0}
|
||||||
|
skillClip: {fileID: -5764696784021583549, guid: 5eaeca917bbeb494eb14ad0e0552c42f, type: 3}
|
||||||
|
endClip: {fileID: 0}
|
||||||
|
animationSpeed: 1
|
||||||
|
useRootMotion: 0
|
||||||
|
ignoreRootMotionY: 0
|
||||||
|
jumpToTarget: 0
|
||||||
|
cooldown: 0
|
||||||
|
manaCost: 0
|
||||||
|
effects:
|
||||||
|
- {fileID: 0}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5320cf0e941c6c044a4c8663f86cd9e2
|
guid: 0e22d4b1dc395a04fb00ca4f82aeb838
|
||||||
NativeFormatImporter:
|
NativeFormatImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
mainObjectFileID: 11400000
|
mainObjectFileID: 11400000
|
||||||
27
Assets/_Game/Data/Skills/Data_Skill_TestBoss_점프착지.asset
Normal file
27
Assets/_Game/Data/Skills/Data_Skill_TestBoss_점프착지.asset
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 94f0a76cebcac2f4fb5daf1b675fd79f, type: 3}
|
||||||
|
m_Name: "Data_Skill_TestBoss_\uC810\uD504\uCC29\uC9C0"
|
||||||
|
m_EditorClassIdentifier: Colosseum.Game::Colosseum.Skills.SkillData
|
||||||
|
skillName: "\uC810\uD504"
|
||||||
|
description:
|
||||||
|
icon: {fileID: 0}
|
||||||
|
skillClip: {fileID: 4379034921508237129, guid: 5eaeca917bbeb494eb14ad0e0552c42f, type: 3}
|
||||||
|
endClip: {fileID: 0}
|
||||||
|
animationSpeed: 1
|
||||||
|
useRootMotion: 0
|
||||||
|
ignoreRootMotionY: 0
|
||||||
|
jumpToTarget: 0
|
||||||
|
cooldown: 0
|
||||||
|
manaCost: 0
|
||||||
|
effects:
|
||||||
|
- {fileID: 11400000, guid: 11bd2d1ebdbfc2f4abf5a9d886615eb3, type: 2}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 16321efbd1f2498458683bac7605b054
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e651dbb3fbac04af2b8f5abf007ddc23, type: 3}
|
|
||||||
m_Name: NetworkPrefabsList
|
|
||||||
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkPrefabsList
|
|
||||||
IsDefault: 0
|
|
||||||
List:
|
|
||||||
- Override: 0
|
|
||||||
Prefab: {fileID: 6473031571298860035, guid: 9f538e60b8b98634b8952310b91dfba0, type: 3}
|
|
||||||
SourcePrefabToOverride: {fileID: 0}
|
|
||||||
SourceHashToOverride: 0
|
|
||||||
OverridingTargetPrefab: {fileID: 0}
|
|
||||||
@@ -15,6 +15,7 @@ using Action = Unity.Behavior.Action;
|
|||||||
public partial class UsePatternAction : Action
|
public partial class UsePatternAction : Action
|
||||||
{
|
{
|
||||||
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern;
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern;
|
||||||
|
[SerializeReference] public BlackboardVariable<GameObject> Target;
|
||||||
|
|
||||||
private SkillController skillController;
|
private SkillController skillController;
|
||||||
private int currentStepIndex;
|
private int currentStepIndex;
|
||||||
@@ -112,6 +113,15 @@ public partial class UsePatternAction : Action
|
|||||||
return Status.Failure;
|
return Status.Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jumpToTarget 스킬이면 타겟 위치 전달
|
||||||
|
if (step.Skill.JumpToTarget)
|
||||||
|
{
|
||||||
|
if (Target?.Value == null)
|
||||||
|
Debug.LogWarning($"[UsePatternAction] '{step.Skill.SkillName}'은 JumpToTarget 스킬이지만 Target이 바인딩되지 않았습니다.");
|
||||||
|
else
|
||||||
|
GameObject.GetComponent<Colosseum.Enemy.EnemyBase>()?.SetJumpTarget(Target.Value.transform.position);
|
||||||
|
}
|
||||||
|
|
||||||
return Status.Running;
|
return Status.Running;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Unity.Properties;
|
|||||||
public partial class UseSkillAction : Action
|
public partial class UseSkillAction : Action
|
||||||
{
|
{
|
||||||
[SerializeReference] public BlackboardVariable<SkillData> 스킬;
|
[SerializeReference] public BlackboardVariable<SkillData> 스킬;
|
||||||
|
[SerializeReference] public BlackboardVariable<GameObject> Target;
|
||||||
|
|
||||||
private SkillController skillController;
|
private SkillController skillController;
|
||||||
|
|
||||||
@@ -42,6 +43,13 @@ public partial class UseSkillAction : Action
|
|||||||
return Status.Failure;
|
return Status.Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jumpToTarget 스킬이면 타겟 위치 전달
|
||||||
|
if (스킬.Value.JumpToTarget && Target?.Value != null)
|
||||||
|
{
|
||||||
|
var enemyBase = GameObject.GetComponent<Colosseum.Enemy.EnemyBase>();
|
||||||
|
enemyBase?.SetJumpTarget(Target.Value.transform.position);
|
||||||
|
}
|
||||||
|
|
||||||
return Status.Running;
|
return Status.Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ namespace Colosseum.Enemy
|
|||||||
// 점프 등 Y 루트모션 스킬 중 NavMeshAgent 비활성화 상태 추적
|
// 점프 등 Y 루트모션 스킬 중 NavMeshAgent 비활성화 상태 추적
|
||||||
private bool isAirborne = false;
|
private bool isAirborne = false;
|
||||||
|
|
||||||
|
// 점프 타겟 이동
|
||||||
|
private bool hasJumpTarget = false;
|
||||||
|
private Vector3 jumpStartXZ;
|
||||||
|
private Vector3 jumpTargetXZ;
|
||||||
|
|
||||||
// 이벤트
|
// 이벤트
|
||||||
public event Action<float, float> OnHealthChanged; // currentHealth, maxHealth
|
public event Action<float, float> OnHealthChanged; // currentHealth, maxHealth
|
||||||
public event Action<float> OnDamageTaken; // damage
|
public event Action<float> OnDamageTaken; // damage
|
||||||
@@ -84,45 +89,50 @@ namespace Colosseum.Enemy
|
|||||||
protected virtual void OnServerUpdate() { }
|
protected virtual void OnServerUpdate() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// NavMeshAgent position sync 및 OnAnimatorMove 이후에 실행됩니다.
|
/// 보스와 플레이어가 겹치면 플레이어를 밀어냅니다.
|
||||||
/// 보스가 이미 플레이어 안으로 들어온 경우 stoppingDistance 바깥으로 밀어냅니다.
|
/// 점프 착지 포함, 항상 실행됩니다.
|
||||||
/// Update()에서의 isStopped 조작은 NavMeshAgent에 의해 덮어써지지만,
|
|
||||||
/// LateUpdate()는 그 이후이므로 확실하게 보정됩니다.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void LateUpdate()
|
private void LateUpdate()
|
||||||
{
|
{
|
||||||
if (!IsServer || IsDead || navMeshAgent == null || isAirborne) return;
|
if (!IsServer || IsDead) return;
|
||||||
|
|
||||||
// stoppingDistance가 0이면 radius 기반 fallback 사용
|
float separationDist = navMeshAgent != null
|
||||||
float stopDist = navMeshAgent.stoppingDistance > 0f
|
? Mathf.Max(navMeshAgent.stoppingDistance, navMeshAgent.radius + 0.5f)
|
||||||
? navMeshAgent.stoppingDistance
|
: 1f;
|
||||||
: navMeshAgent.radius + 0.5f;
|
|
||||||
|
|
||||||
int count = Physics.OverlapSphereNonAlloc(transform.position, stopDist, overlapBuffer);
|
int count = Physics.OverlapSphereNonAlloc(transform.position, separationDist, overlapBuffer);
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
// 레이어 무관하게 CharacterController 유무로 플레이어 식별
|
if (!overlapBuffer[i].TryGetComponent<CharacterController>(out var cc)) continue;
|
||||||
if (!overlapBuffer[i].TryGetComponent<CharacterController>(out _)) continue;
|
|
||||||
|
|
||||||
Vector3 toPlayer = overlapBuffer[i].transform.position - transform.position;
|
Vector3 toPlayer = overlapBuffer[i].transform.position - transform.position;
|
||||||
toPlayer.y = 0f;
|
toPlayer.y = 0f;
|
||||||
float dist = toPlayer.magnitude;
|
float dist = toPlayer.magnitude;
|
||||||
if (dist >= stopDist) continue;
|
if (dist >= separationDist) continue;
|
||||||
|
|
||||||
// 보스가 실제로 이동 중일 때만 밀어냄.
|
// 플레이어를 보스 바깥으로 밀어냄
|
||||||
// isStopped는 수동 설정 시만 true가 되므로, velocity로 실제 이동 여부를 판단.
|
Vector3 pushDir = dist > 0.001f ? toPlayer.normalized : transform.forward;
|
||||||
if (navMeshAgent.velocity.sqrMagnitude > 0.01f)
|
cc.Move(pushDir * (separationDist - dist));
|
||||||
{
|
|
||||||
Vector3 pushDir = dist > 0.001f ? -toPlayer.normalized : -transform.forward;
|
// 보스가 이동 중이었으면 정지 (플레이어 안으로 더 진입하지 않도록)
|
||||||
navMeshAgent.Warp(transform.position + pushDir * (stopDist - dist));
|
if (navMeshAgent != null && !isAirborne && navMeshAgent.velocity.sqrMagnitude > 0.01f)
|
||||||
navMeshAgent.isStopped = true;
|
navMeshAgent.isStopped = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 점프 타겟 설정. UseSkillAction에서 jumpToTarget 스킬 시전 시 호출합니다.
|
||||||
|
/// </summary>
|
||||||
|
public void SetJumpTarget(Vector3 targetPos)
|
||||||
|
{
|
||||||
|
jumpTargetXZ = new Vector3(targetPos.x, 0f, targetPos.z);
|
||||||
|
hasJumpTarget = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 보스 스킬 루트모션이 플레이어 방향으로 진입하는 것을 차단합니다.
|
/// 보스 스킬 루트모션이 플레이어 방향으로 진입하는 것을 차단합니다.
|
||||||
/// Y 루트모션이 필요한 스킬(점프 등)은 NavMeshAgent를 비활성화하고 직접 이동합니다.
|
/// Y 루트모션이 필요한 스킬(점프 등)은 NavMeshAgent를 비활성화하고 직접 이동합니다.
|
||||||
|
/// jumpToTarget 스킬은 XZ를 대상 위치로 lerp합니다.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnAnimatorMove()
|
private void OnAnimatorMove()
|
||||||
{
|
{
|
||||||
@@ -131,30 +141,12 @@ namespace Colosseum.Enemy
|
|||||||
var skillCtrl = GetComponent<Colosseum.Skills.SkillController>();
|
var skillCtrl = GetComponent<Colosseum.Skills.SkillController>();
|
||||||
bool needsYMotion = skillCtrl != null
|
bool needsYMotion = skillCtrl != null
|
||||||
&& skillCtrl.IsPlayingAnimation
|
&& skillCtrl.IsPlayingAnimation
|
||||||
|
&& !skillCtrl.IsInEndAnimation
|
||||||
&& skillCtrl.UsesRootMotion
|
&& skillCtrl.UsesRootMotion
|
||||||
&& !skillCtrl.IgnoreRootMotionY;
|
&& !skillCtrl.IgnoreRootMotionY;
|
||||||
|
|
||||||
Vector3 deltaPosition = animator.deltaPosition;
|
Vector3 deltaPosition = animator.deltaPosition;
|
||||||
|
|
||||||
// XZ 차단: 플레이어 방향으로의 이동 방지
|
|
||||||
float blockRadius = Mathf.Max(navMeshAgent.stoppingDistance, navMeshAgent.radius + 0.5f);
|
|
||||||
int count = Physics.OverlapSphereNonAlloc(transform.position, blockRadius, overlapBuffer);
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
if (!overlapBuffer[i].TryGetComponent<CharacterController>(out _)) continue;
|
|
||||||
|
|
||||||
Vector3 toPlayer = overlapBuffer[i].transform.position - transform.position;
|
|
||||||
toPlayer.y = 0f;
|
|
||||||
if (toPlayer.sqrMagnitude < 0.0001f) continue;
|
|
||||||
|
|
||||||
Vector3 deltaXZ = new Vector3(deltaPosition.x, 0f, deltaPosition.z);
|
|
||||||
if (Vector3.Dot(deltaXZ, toPlayer.normalized) > 0f)
|
|
||||||
{
|
|
||||||
deltaPosition.x = 0f;
|
|
||||||
deltaPosition.z = 0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needsYMotion)
|
if (needsYMotion)
|
||||||
{
|
{
|
||||||
// Y 루트모션 필요: NavMeshAgent 비활성화 후 transform 직접 이동
|
// Y 루트모션 필요: NavMeshAgent 비활성화 후 transform 직접 이동
|
||||||
@@ -162,8 +154,21 @@ namespace Colosseum.Enemy
|
|||||||
{
|
{
|
||||||
navMeshAgent.enabled = false;
|
navMeshAgent.enabled = false;
|
||||||
isAirborne = true;
|
isAirborne = true;
|
||||||
|
jumpStartXZ = new Vector3(transform.position.x, 0f, transform.position.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasJumpTarget)
|
||||||
|
{
|
||||||
|
// XZ: 애니메이션 진행도에 따라 목표 위치로 lerp
|
||||||
|
float t = Mathf.Clamp01(animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
|
||||||
|
Vector3 newXZ = Vector3.Lerp(jumpStartXZ, jumpTargetXZ, t);
|
||||||
|
transform.position = new Vector3(newXZ.x, transform.position.y + deltaPosition.y, newXZ.z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// jumpToTarget 없으면 기존처럼 애니메이션 루트모션 그대로 적용
|
||||||
|
transform.position += deltaPosition;
|
||||||
}
|
}
|
||||||
transform.position += deltaPosition;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -171,9 +176,35 @@ namespace Colosseum.Enemy
|
|||||||
if (isAirborne)
|
if (isAirborne)
|
||||||
{
|
{
|
||||||
isAirborne = false;
|
isAirborne = false;
|
||||||
|
if (hasJumpTarget)
|
||||||
|
{
|
||||||
|
// lerp가 1.0에 못 미쳐도 착지 시 정확한 위치로 스냅
|
||||||
|
transform.position = new Vector3(jumpTargetXZ.x, transform.position.y, jumpTargetXZ.z);
|
||||||
|
}
|
||||||
|
hasJumpTarget = false;
|
||||||
navMeshAgent.enabled = true;
|
navMeshAgent.enabled = true;
|
||||||
navMeshAgent.Warp(transform.position);
|
navMeshAgent.Warp(transform.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XZ 차단: 플레이어 방향으로의 이동 방지 (일반 이동 중에만)
|
||||||
|
float blockRadius = Mathf.Max(navMeshAgent.stoppingDistance, navMeshAgent.radius + 0.5f);
|
||||||
|
int count = Physics.OverlapSphereNonAlloc(transform.position, blockRadius, overlapBuffer);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (!overlapBuffer[i].TryGetComponent<CharacterController>(out _)) continue;
|
||||||
|
|
||||||
|
Vector3 toPlayer = overlapBuffer[i].transform.position - transform.position;
|
||||||
|
toPlayer.y = 0f;
|
||||||
|
if (toPlayer.sqrMagnitude < 0.0001f) continue;
|
||||||
|
|
||||||
|
Vector3 deltaXZ = new Vector3(deltaPosition.x, 0f, deltaPosition.z);
|
||||||
|
if (Vector3.Dot(deltaXZ, toPlayer.normalized) > 0f)
|
||||||
|
{
|
||||||
|
deltaPosition.x = 0f;
|
||||||
|
deltaPosition.z = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
navMeshAgent.Move(deltaPosition);
|
navMeshAgent.Move(deltaPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace Colosseum.Skills
|
|||||||
|
|
||||||
public bool IsExecutingSkill => currentSkill != null && !skillEndRequested;
|
public bool IsExecutingSkill => currentSkill != null && !skillEndRequested;
|
||||||
public bool IsPlayingAnimation => currentSkill != null;
|
public bool IsPlayingAnimation => currentSkill != null;
|
||||||
|
public bool IsInEndAnimation => waitingForEndAnimation;
|
||||||
public bool UsesRootMotion => currentSkill != null && currentSkill.UseRootMotion;
|
public bool UsesRootMotion => currentSkill != null && currentSkill.UseRootMotion;
|
||||||
public bool IgnoreRootMotionY => currentSkill != null && currentSkill.IgnoreRootMotionY;
|
public bool IgnoreRootMotionY => currentSkill != null && currentSkill.IgnoreRootMotionY;
|
||||||
public SkillData CurrentSkill => currentSkill;
|
public SkillData CurrentSkill => currentSkill;
|
||||||
@@ -143,6 +144,7 @@ namespace Colosseum.Skills
|
|||||||
// 스킬 애니메이션 재생
|
// 스킬 애니메이션 재생
|
||||||
if (skill.SkillClip != null && animator != null)
|
if (skill.SkillClip != null && animator != null)
|
||||||
{
|
{
|
||||||
|
animator.speed = skill.AnimationSpeed;
|
||||||
PlaySkillClip(skill.SkillClip);
|
PlaySkillClip(skill.SkillClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,6 +214,7 @@ namespace Colosseum.Skills
|
|||||||
if (animator != null && baseController != null)
|
if (animator != null && baseController != null)
|
||||||
{
|
{
|
||||||
animator.runtimeAnimatorController = baseController;
|
animator.runtimeAnimatorController = baseController;
|
||||||
|
animator.speed = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 클라이언트에 복원 동기화
|
// 클라이언트에 복원 동기화
|
||||||
|
|||||||
@@ -20,12 +20,16 @@ namespace Colosseum.Skills
|
|||||||
[SerializeField] private AnimationClip skillClip;
|
[SerializeField] private AnimationClip skillClip;
|
||||||
[Tooltip("종료 애니메이션 (선택)")]
|
[Tooltip("종료 애니메이션 (선택)")]
|
||||||
[SerializeField] private AnimationClip endClip;
|
[SerializeField] private AnimationClip endClip;
|
||||||
|
[Tooltip("애니메이션 재생 속도 (1 = 기본, 2 = 2배속)")]
|
||||||
|
[Min(0.1f)] [SerializeField] private float animationSpeed = 1f;
|
||||||
|
|
||||||
[Header("루트 모션")]
|
[Header("루트 모션")]
|
||||||
[Tooltip("애니메이션의 이동/회전 데이터를 캐릭터에 적용")]
|
[Tooltip("애니메이션의 이동/회전 데이터를 캐릭터에 적용")]
|
||||||
[SerializeField] private bool useRootMotion = false;
|
[SerializeField] private bool useRootMotion = false;
|
||||||
[Tooltip("루트 모션 적용 시 Y축 이동 무시 (중력과 충돌)")]
|
[Tooltip("루트 모션 적용 시 Y축 이동 무시 (중력과 충돌)")]
|
||||||
[SerializeField] private bool ignoreRootMotionY = true;
|
[SerializeField] private bool ignoreRootMotionY = true;
|
||||||
|
[Tooltip("스킬 시전 시 대상 위치로 점프 이동 (UseRootMotion + IgnoreRootMotionY=false 필요)")]
|
||||||
|
[SerializeField] private bool jumpToTarget = false;
|
||||||
|
|
||||||
[Header("쿨타임 & 비용")]
|
[Header("쿨타임 & 비용")]
|
||||||
[Min(0f)] [SerializeField] private float cooldown = 1f;
|
[Min(0f)] [SerializeField] private float cooldown = 1f;
|
||||||
@@ -41,10 +45,12 @@ namespace Colosseum.Skills
|
|||||||
public Sprite Icon => icon;
|
public Sprite Icon => icon;
|
||||||
public AnimationClip SkillClip => skillClip;
|
public AnimationClip SkillClip => skillClip;
|
||||||
public AnimationClip EndClip => endClip;
|
public AnimationClip EndClip => endClip;
|
||||||
|
public float AnimationSpeed => animationSpeed;
|
||||||
public float Cooldown => cooldown;
|
public float Cooldown => cooldown;
|
||||||
public float ManaCost => manaCost;
|
public float ManaCost => manaCost;
|
||||||
public bool UseRootMotion => useRootMotion;
|
public bool UseRootMotion => useRootMotion;
|
||||||
public bool IgnoreRootMotionY => ignoreRootMotionY;
|
public bool IgnoreRootMotionY => ignoreRootMotionY;
|
||||||
|
public bool JumpToTarget => jumpToTarget;
|
||||||
public IReadOnlyList<SkillEffect> Effects => effects;
|
public IReadOnlyList<SkillEffect> Effects => effects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user