[UE5 KDT2024] 18. 애니메이션 동기화
1. 몽타주에 트랙을 넣어보자
1) BPAM_PlayerKnightAttack 에디터에서 노티파이 - 노티파이 트랙 추가




2) 애니메이션 사운드 넣어보자
(1) 노티파이 트랙추가(트랙별로 구분하는게 깔끔할듯) - 노티파이 추가 - 사운드재생
(2) 디테일창 - 사운드에서 설정해주기

3) 트레일 넣어보자 : 칼 궤적같은거
(1) 노티파이 트랙 추가해서 구분 - 노티파이 스테이트 추가 - 트레일



(2) 디테일창
- PS 템플릿 : 트레일 이펙트
- 첫번째 소켓 이름 : 트레일 시작될 본 소켓 이름
- 두번째 소켓 이름 : 트레일 이어질 소켓이름
- 본소켓은 해골모양 아이콘 (빨간네모칸)가서 찾아서 더블클릭해서 이름 복사해오면 됨
제대로 넣으면 칼끝 궤적이 생김
=> 모든 트레일 다중 선택하고 한번에 입력 가능
=> 실행하면 공격할때 칼끝에 궤적 생김
2. 서버, 클라간 공격 애니메이션 동기화
1) PlayerBase.h에서 AttackAction을 virtual 키워드 추가
..
UFUNCTION()
virtual void AttackAction( const struct FInputActionValue& value );
2) PlayerKnight.h
// BlueprintCallable : 블루프린트에서 호출 가능
// Server : 서버에서 실행
// Reliable : 반드시 전달
UFUNCTION( BlueprintCallable, Server, Reliable )
void ChangeAnimation_Server( int32 animType );
void ChangeAnimation_Server_Implementation( int32 animType );
// NetMulticast : 서버와 연결된 모든 클라이언트에서 실행
UFUNCTION( BlueprintCallable, NetMulticast, Reliable )
void ChangeAnimation_MultiCast( int32 animType );
void ChangeAnimation_MultiCast_Implementation( int32 animType );
..
virtual void AttackAction( const struct FInputActionValue& value ) override;
3) PlayerKnight 구현
void APlayerKnight::ChangeAnimation_Server_Implementation( int32 animType )
{
// 게임모드는 서버 - 클라이언트일 때, 서버에만 생긴다.
AGameModeBase* gameMode = GetWorld()->GetAuthGameMode();
if ( IsValid( gameMode ) )
ChangeAnimation_MultiCast( animType );
}
void APlayerKnight::ChangeAnimation_MultiCast_Implementation( int32 animType )
{
if ( IsValid( mAnim ) )
mAnim->PlayAttackMonatage();
}
void APlayerKnight::AttackAction( const FInputActionValue& value )
{
ChangeAnimation_Server( 0 );
}
=> 이 상태에서 플레이어 2명, 리슨서버로 설정하고 실행해보자
공격할 때 gameMode에 브레이크포인트 걸고 확인하면
서버일때만 gameMode를 가지고 있다.
=> 각각 화면에서 이동, 공격 애니가 동기화됨을 알 수 있다.
-> ChangeAnimation_Server_Implementation()
게임모드가 서버면 모든 클라이언트에게 공격 애니 실행 호출(ChangeAnimation_MultiCast( animType );
-> ChangeAnimation_MultiCast_Implementation()
공격애니실행
3. 에임오프셋
▶️에임오프셋
: 시야 볼 때, 캐릭터 고개가 따라가기, 마우스 따라서 카메라 움직이기
1) 입력액션 추가
(1) 블프/input 폴더에 - 입력 - 입력액션 - IA_Rotation
값 타입 : Axis2D

(2) IA_Context에 IA_Rotation 매핑 추가

- 마우스 X, 마우스Y 추가
- 마우스 Y 모디파이어에 스위즐 입력 축값 인덱스 추가
2) 입력 시스템 추가
DefaultInputSystem.h
...
UPROPERTY ( EditAnywhere, BlueprintReadWrite )
class UInputAction* mRotation;
생성자
...
static ConstructorHelpers::FObjectFinder<UInputAction>
rotationAction ( L"/Script/EnhancedInput.InputAction'/Game/Blueprint/Input/IA_Rotation.IA_Rotation'" );
if ( rotationAction.Succeeded () )
mRotation = rotationAction.Object;
3) PlayerBase 회전 연결
header
..
UPROPERTY ( VisibleAnywhere )
FRotator mCameraRotator;
..
// 마우스 움직임에 따라 카메라 이동 및 축 적용
UFUNCTION ()
virtual void RotationAction ( const struct FInputActionValue& value );
cpp
void APlayerBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
..
inputCp->BindAction( mDefaultInput->mRotation, ETriggerEvent::Triggered, this, &APlayerBase::RotationAction );
}
4) 에임오프셋 애니메이션 추가

애니메이션 - 에임오프셋 - AO_PlayerKnight_Idle 추가
카메라 휠값에 따라 화면 확대 축소
▶️ ctrl + Shift + f9 : 모든 중단점 제거