-
[Unreal] Spectator Pawn Input이 제대로 안되는 경우쾌락없는 책임 (공부)/Unreal 2023. 7. 5. 15:21반응형
개요 - 상황 설명
현재 플레이어는 WASD와 마우스 좌클릭을 사용하고 있는 상태입니다. 여기서 죽고 나면 Spectator Pawn을 생성해 A, D, 마우스 좌, 우클릭을 통해서 관전할 플레이어를 조작할 수 있게 계획했습니다.
그런데 Spectator Pawn을 생성하고 나면 마우스 우클릭만 사용이 가능하고 기존 플레이어가 사용하고 있는 Input을 사용할 수 없는 문제가 있었습니다. 여기서 다짜고짜 Spectator Pawn의 IMC 우선순위를 높여버리면 Spectator Pawn이 게임 시작과 동시에 생성되면서 Input을 Spectator Pawn이 먹는 문제가 있습니다.
해결법 - ClearAllMappings
void AFASpectatorPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); if(const auto PlayerController = Cast<APlayerController>(GetController())) { if(const auto Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer())) { Subsystem->ClearAllMappings(); Subsystem->AddMappingContext(SpectorBasicMappingContext, 0); } } //... }
ClearAllMappings 함수를 사용하면 이전 플레이어가 사용하고 있던 IMC 조합들을 전부 날려버릴 수 있기 때문에 이 방법을 사용하면 Spectator Pawn이 이후 생성되고 나서 IMC 매핑을 원활하게 할 수 있습니다.
반응형'쾌락없는 책임 (공부) > Unreal' 카테고리의 다른 글
[Unreal] Render Through Object, 오브젝트 뒤에 있는 플레이어 보이게 하기 (0) 2023.07.12 [Unreal] CustomDepth Stencil Value 결과가 이상한 경우 (1) 2023.07.11 [Unreal] Seamless, non Seamless (0) 2023.06.20 [Unreal] Unreal ToolTip, 툴팁 추가해보기 (0) 2023.05.24 [Unreal] 언리얼 멀티플레이에서 얻어낸 간단 팁들 (2) 2023.05.18