Infinite Fighter 개발일지 (7)

유영준·2023년 5월 1일
1

UE5 UNSEEN

목록 보기
7/18

2023.04.24 ~ 2023.04.30 개발일지

추가한 부분

무기와 캐릭터 프로파일 추가

캐릭터와 무기의 오브젝트 채널을 추가했다

각각 캐릭터는 기본은 Block, 무기는 Overlap으로 설정했으며, 이에 따른 프리셋을 추가로 설정해주었다

도끼를 던졌을때 Line Trace를 하게 됨으로 캐릭터는 도끼의 레이캐스트에 간섭되지 않도록 Visibility를 Ignore로 해주었다

적에게 도끼가 맞는 것을 구현하기 위해 CharacterMesh 는 Visibility를 Block로 설정하였다

이후 도끼가 잘 박히는것을 확인할 수 있었다


회피 기능 추가

Root Motion이 적용된 8가지 방향의 Dodge 애니메이션과 Roll 애니메이션 애셋을 사용하였다 (19년 당시 무료로 풀어줬었다..)

각각의 애니메이션을 몽타주로 만들고 AnimInstance에서 불러주었다

몽타주는 Blend Space 처럼 하나의 파일에 모든 방향을 지정해줄 수 없기 때문에, 8가지 몽타주를 8방향에 맞춰 실행하는 방식으로 구현하였다

이때 방향은 Character의 move함수에서 받는 Input Value를 매개변수로 받아 사용하였다

IFChracter.cpp

void AIFCharacter::Move(const FInputActionValue& Value)
{
	MovementVector = Value.Get<FVector2D>();
	
    ...
    
}

void AIFCharacter::Evade()
{
	AnimInstance->PlayDodgeMontage(MovementVector.GetSafeNormal());
}

IFCharacterAnimInstance.cpp

void UIFCharacterAnimInstance::PlayDodgeMontage(FVector2D Direction)
{
    if (bCanDoNextAction && !bIsDodging)
    {
        bIsDodging = true;
        if (Direction.X >= -0.5 && Direction.X < 0.5 && Direction.Y > 0.5)
            Montage_Play(DodgeForwardMontage);
        else if (Direction.X >= 0.5 && Direction.Y >= 0.5)
            Montage_Play(DodgeForwardRightMontage);
        else if (Direction.X > 0.5 && Direction.Y < 0.5 && Direction.Y >= -0.5)
            Montage_Play(DodgeRightMontage);
        else if (Direction.X > 0.5 && Direction.Y < -0.5)
            Montage_Play(DodgeBackRightMontage);
        else if (Direction.X < -0.5 && Direction.Y > 0.5)
            Montage_Play(DodgeForwardLeftMontage);
        else if (Direction.X < -0.5 && Direction.Y < 0.5 && Direction.Y >= -0.5)
            Montage_Play(DodgeLeftMontage);
        else if (Direction.X <= -0.5 && Direction.Y <= -0.5)
            Montage_Play(DodgeBackLeftMontage);
        else
            Montage_Play(DodgeBackMontage);
    }
    else if (bCanDoNextAction && bIsDodging)
    {
		if (Direction.X >= -0.5 && Direction.X < 0.5 && Direction.Y > 0.5)
            Montage_Play(RollForwardMontage);
		else if (Direction.X >= 0.5 && Direction.Y >= 0.5)
            Montage_Play(RollForwardRightMontage);
		else if (Direction.X > 0.5 && Direction.Y < 0.5 && Direction.Y >= -0.5)
            Montage_Play(RollRightMontage);
		else if (Direction.X > 0.5 && Direction.Y < -0.5)
            Montage_Play(RollBackRightMontage);
		else if (Direction.X < -0.5 && Direction.Y > 0.5)
            Montage_Play(RollForwardLeftMontage);
		else if (Direction.X < -0.5 && Direction.Y < 0.5 && Direction.Y >= -0.5)
            Montage_Play(RollLeftMontage);
		else if (Direction.X <= -0.5 && Direction.Y <= -0.5)
            Montage_Play(RollBackLeftMontage);
        else
            Montage_Play(RollBackMontage);
    }
}

이때 스탭을 밟고 있는 중이라면 구르기를 실행하도록 구현하였다

즉 스탭 -> 구르기 순서로 나가고, 스탭이 종료될때까지 구르지 않는다면 다시 스탭을 밟는 방식이다


개선점 / 아쉬운 점

개인적으로 8가지 방향에 대해 if문을 잔뜩 걸어두는 방식은 가독성 측면에서도, 코드의 질적으로도 좋지 않다고 느껴진다

이를 개선할 수 있는 방식에 대해, 그리고 가능하다면 몽타주를 방향별로 8개를 만드는 방식이 아닌 다른 방식으로 개선하고 싶다

profile
토비폭스가 되고픈 게임 개발자

0개의 댓글