DEG-28 DEG-33 [feat] 세로로 베기 애니메이션 작업

This commit is contained in:
fiore 2025-04-18 17:08:15 +09:00
parent d14dd89c50
commit 620e91a20a
17 changed files with 110 additions and 34 deletions

View File

@ -49,6 +49,7 @@ public class EnemyControllerEditor : Editor
EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical();
EditorGUILayout.Space(); EditorGUILayout.Space();
GUI.backgroundColor= Color.clear;
EditorGUILayout.LabelField("상태 변경", EditorStyles.boldLabel); EditorGUILayout.LabelField("상태 변경", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();

BIN
Assets/JYY/Animation/Attack01 Slice.anim (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df0c94f0a0eae85438a0bfc0deea8791
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/JYY/Animation/Attack01.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6019f1b4a095b0b4396f5561a51fee89 guid: 34b2cc555a0977644ab2d9e2350a939d
timeCreated: 1544605028
licenseType: Store
NativeFormatImporter: NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

BIN
Assets/JYY/Animation/Attack02.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5a90fe33bc8ca56649ae0d4bc09a37bbd8a0c1312ba47f84aafe8472e01d997d
size 349048

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8cda71f7a8c35a448a6e9999adab5bc1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/JYY/Animation/WindUp.anim (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8d4a1a2c3f67c5c45a3a85dbf83e008b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

BIN
Assets/JYY/Scenes/MonsterTest.unity (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAnimatorStateAttack : StateMachineBehaviour
{
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
// override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
// {
// animator.gameObject.GetComponent<EnemyController>().SetState(EnemyState.Trace);
// }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5765847dbef51e4f9bccde712eeda30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -20,9 +20,12 @@ public abstract class EnemyController : CharacterBase
public float WalkSpeed => walkSpeed; public float WalkSpeed => walkSpeed;
public float RunSpeed => runSpeed; public float RunSpeed => runSpeed;
public Transform TraceTargetTransform { get; private set; }
[SerializeField] private float walkSpeed = 5; [SerializeField] private float walkSpeed = 5;
[SerializeField] private float runSpeed = 8; [SerializeField] private float runSpeed = 8;
// ----- // -----
// 상태 변수 // 상태 변수
private EnemyStateIdle _enemyStateIdle; private EnemyStateIdle _enemyStateIdle;
@ -86,15 +89,16 @@ public abstract class EnemyController : CharacterBase
#region #region
// 일정 반경에 플레이어가 진입하면 플레이어 소리를 감지했다고 판단 // 일정 반경에 플레이어가 진입하면 플레이어 소리를 감지했다고 판단
// TODO : 상태 변경시 바로 앞에 플레이어가 있으면 찾지 못하는 이슈 있음
public Transform DetectPlayerInCircle() public Transform DetectPlayerInCircle()
{ {
var hitColliders = Physics.OverlapSphere(transform.position, var hitColliders = Physics.OverlapSphere(transform.position,
detectCircleRadius, targetLayerMask); detectCircleRadius, targetLayerMask);
if (hitColliders.Length > 0) if (hitColliders.Length > 0)
{ {
return hitColliders[0].transform; TraceTargetTransform = hitColliders[0].transform;
return TraceTargetTransform;
} }
return null; return null;
} }

View File

@ -4,39 +4,52 @@ using UnityEngine;
public class EnemyStateAttack : IEnemyState public class EnemyStateAttack : IEnemyState
{ {
private EnemyController _enemyController; private EnemyController _enemyController;
private Animator _animator;
private Coroutine _attackRoutine;
public void Enter(EnemyController enemyController) public void Enter(EnemyController enemyController)
{ {
_enemyController = enemyController; _enemyController = enemyController;
_enemyController.EnemyAnimator.SetTrigger("Attack"); _animator = _enemyController.EnemyAnimator;
_animator.SetBool("Attack", true);
_attackRoutine = _enemyController.StartCoroutine(AttackSequence());
} }
public void Update() public void Update()
{ {
}
private IEnumerator AttackSequence()
{
// 1. 전조 이펙트 생성
// 2. 검을 들어올림
yield return new WaitForSeconds(3f);
// 3. 대기(전조와 검 들어올리는 애니메이션을 위함)
// 4. 전조 제거
// 5. 검 휘두르기
_animator.SetTrigger("VertiSlash");
// 6. 공격 판정 발생
yield return new WaitForSeconds(1f);
// 7. 애니메이션 트리거 종료 -> 애니메이터 상태 머신으로 처리
_enemyController.SetState(EnemyState.Trace); _enemyController.SetState(EnemyState.Trace);
} }
// private IEnumerator AttackSequence()
// {
// // 1. 전조 이펙트 생성
//
// // 2. 검을 들어올리는 애니메이션 재생
//
// // 3. 대기(전조와 검 들어올리는 애니메이션을 위함)
//
// // 4. 전조 제거
//
// // 회전 초기화
//
// // 5. 검 휘두르기
//
// // 6. 공격 판정 발생
//
// // 7. 상태 전환
// }
public void Exit() public void Exit()
{ {
if (_attackRoutine != null)
{
_enemyController.StopCoroutine(_attackRoutine);
_attackRoutine = null;
}
_animator.SetBool("Attack", false);
_animator = null;
_enemyController = null; _enemyController = null;
} }
} }

View File

@ -15,7 +15,7 @@ public class EnemyStateTrace : IEnemyState
{ {
_enemyController = enemyController; _enemyController = enemyController;
_detectPlayerTransform = _enemyController.DetectPlayerInCircle(); _detectPlayerTransform = _enemyController.TraceTargetTransform;
if (!_detectPlayerTransform) if (!_detectPlayerTransform)
{ {
_enemyController.SetState(EnemyState.Idle); _enemyController.SetState(EnemyState.Idle);