1인 개발/PushAndSlash

푸쉬앤슬래시 개인 프로젝트 5일차

잼잼재미 2024. 5. 7. 23:08

구현 내용


1. 넉백 구현


 

  • 무기에 콜라이더 적용 
  • EnemyHitState 추가
  • Player 넉백 구현
  • Enemy 넉백 구현 (기본 공격, 스킬)

 

if (_enemyController.IsHit_attack || _enemyController.IsHit_skill)
{
    _enemyController.HitStart();
    _enemyController.Animator.SetTrigger("Hit");
    break;
}

 

IsHit_attack, IsHit_skill 변수를 설정해서 HitState로 전환

 

 

_dir = (transform.position - _enemyController.Target.transform.position).normalized;

if(_enemyController.IsHit_attack)
{
    _enemyController.Rigidbody.velocity = _dir * (_enemyController.PlayerData.Atk - _enemyController.Def);
}
else if(_enemyController.IsHit_skill)
{
    _enemyController.Rigidbody.velocity = _dir * (_enemyController.PlayerData.SkillAtk - _enemyController.Def);
}

 

적이 attack과 skill 공격을 받았을 때를 구분해서 각각 넉백을 구현

 

 

회고


Player와 Enemy에 데미지를 적용하기 위해 콜라이더를 추가했다. 기본 공격의 경우 무기에 직접 콜라이더를 설정 후, 애니메이션에서 공격 모션에서 잠깐만 콜라이더를 활성화 시켜서 데미지를 적용했다. 스킬은 경우 기본 공격보다 범위를 넓게 설정하기 위해 Boxcollider를 설정했다. 데미지 적용 후, 적의 HitState를 구현해서 넉백을 적용했다. 기본적인 Player와 Enemy의 구현은 거의 마쳤기 때문에 적 프리팹을 배치 후, 간단한 게임 클리어를 구현하도록 하겠다!