
UML로 요약하기
PlayerBase
이전 PlayerBase
빠졌던 입력에 대한 함수들을 추가했고 Sword로 옮길 것들은 다 지웠다.
PlayerSword
PlayerBase를 상속받는 PlayerSword이다.
SwordMontageComponent를 여기서 Create하고 Getter함수도 만들어준다.
SwordMontageComponent를 사용하는 함수 LeftMouseButtonStarted, TabStarted, AttackFinished 를 override 하였다.
UML로 요약하기
WeaponBase
이전 WeaponBase이다.
스켈레탈 메시 컴포넌트와 메시 변수를 남겼고, Attach함수와 AttackFinished
는 virtual로 선언하여 override할수 있도록 했다.WeaponSword
Sword용 BoxCollision, SceneComponent, Strength등 기존 Sword용으로 만들었던 것들을 다 옮겼다. 함수도 그대로 옮겼다.
AnimNotify, AnimNotifyState
Sword관련 노티파이와 노티파이 스테이트들을 수정해주었다.
기존에 캐릭터의 정면인지 검사하는 IsInScreen 함수에선 내부에서 플레이어 정면 벡터와 적 캐릭터를 향한 방향벡터의 각도를 구해서 앞 뒤 여부를 판별했는데 그냥 각도를 구하는 함수로 바꿨다.
float UTargetComponent::GetTheta(const FVector& InPlayerLocation, const FVector& InPlayerForwardVector, const FVector& InTargetLocation) { const FVector targetLocation(InTargetLocation.X, InTargetLocation.Y, InPlayerLocation.Z); FVector directionVector = targetLocation - InPlayerLocation; directionVector.Normalize(); double theta = FMath::RadiansToDegrees(FMath::Acos(InPlayerForwardVector | directionVector)); return theta; }Trace된 적 캐릭터들을 for문으로 순회하면서 각도를 구한 뒤 캐릭터의 앞에 있는지 체크하고, 가장 각도가 작은 적 (에임에 가장 가까운 적)을 타겟액터로 정한다.
결과
좀 더 플레이어가 원하는 목표를 타게팅 할 수 있도록 잘 수정되었다.