이 하우투 튜토리얼에서는 삼인칭 예시 맵에서 게임플레이 도중 플레이어 시점에 사용될 스태틱(또는 고정) 카메라 앵글을 생성한 다음, 캐릭터가 볼륨과 겹쳐질 때 새 스태틱 카메라로 시점을 트랜지션하는 트리거 볼륨을 생성할 것입니다. 이 튜토리얼을 완료하면 여기 사용된 프로세스를 여러분의 게임에 적용하여 플레이어를 위한 고정 시점을 구성할 수 있습니다.
스태틱 카메라 액터 생성
Begin by creating a New > Games > Third Person > C++ project named StaticCameras.
Launch the C++ Class Wizard, enable the checkbox for Show All Classes, then type CameraActor within the search field to select and create your new Camera Actor class named ExampleCameraActor.
From the C++ Class panel, right click on your ExampleCamera and from the dropdown C++ Class actions menu select Create a Blueprint class based on ExampleCameraActor. Then drag an instance of BP_ExampleCameraActor into the level.
레벨 구성
플레이어 카메라와 스태틱 카메라 액터 사이의 시점 트랜지션을 보여주기 위해서는 씬을 구성해야 합니다. 그렇게 하려면 삼인칭 템플릿 레벨에서 스태틱 메시 지오메트리 일부를 수정합니다.
우선 월드 아웃라이너(World Outliner) 패널로 이동한 뒤, ArenaGeometry > Arena 폴더에서 Shift를 누른 채로 Floor와 4개의 Wall 스태틱 메시 액터를 선택합니다.
위 예시 이미지에서 4개의 Wall 스태틱 메시 액터는 Wall6, Wall7, Wall8, Wall9입니다.
트랜스폼(Transform) 기즈모를 Alt+클릭하고 드래그하여 바닥 및 벽 구성의 복제를 생성합니다.
그렇게 하면 두 번째 Floor와 4개의 추가 Wall 스태틱 메시 액터가 생성됩니다.
위 예시 이미지에서 복제된 바닥은 Floor2로 라벨이 지정되었고, 복제된 벽은 Wall10, Wall11, Wall12, Wall13으로 명명되었습니다.
새로 복제된 스태틱 메시를 아래 레이아웃과 같이 움직여서 이전 방과 같지만 콘텐츠가 없는 새 방을 만듭니다.
월드 아웃라이너(World Outliner)에서 두 방을 연결하는 두 벽을 선택한 다음 스케일(Scale) X 값을 14로 설정합니다.
위 예시 이미지에서 두 벽의 라벨은 Wall9와 Wall12입니다.
아래 GIF처럼 연결하는 두 벽을 모두 선택한 다음 트랜스폼(Transform) 기즈모로 움직여서 방 사이에 파티션을 형성합니다.
위 예시 이미지에서 두 벽의 라벨은 Wall9와 Wall10입니다.
완성된 레벨은 아래 이미지처럼 두 번째 방이 벽의 틈새를 통해 첫 번째 방과 연결된 모습일 것입니다.
카메라 시점 구성
레벨 구성을 마쳤으니 BP_ExampleCameraActor를 레벨에 배치하여 플레이어가 트리거 볼륨과 겹쳐졌을 때 어떤 뷰를 보게 될지 더 잘 파악할 수 있습니다. 뷰포트(Viewport)를 카메라 액터에 고정하고 파일럿(Pilot) 모드에 들어가면 카메라 위치에서 일인칭 시점으로 볼 수 있습니다.
레벨에서 카메라를 선택한 다음 카메라를 우클릭하고 컨텍스트 메뉴에서 파일럿 CameraActor(Pilot CameraActor)를 선택합니다.
이제 왼쪽 또는 오른쪽 마우스 버튼을 누른 채로 WASD 키를 사용해서 뷰포트 안을 이동할 수 있습니다. 레벨 안을 이동하는 동안 사용자의 움직임에 따라 카메라가 움직이기 때문에 게임플레이 동안 카메라 시점이 어떨지 파악할 수 있습니다.
카메라를 잠금 해제하려면 잠금 해제(Unlock) 버튼을 클릭합니다.
카메라는 잠금 해제한 위치에 유지됩니다. 잠금 해제 버튼 옆의 아이콘을 클릭하면 인게임 카메라 뷰와 레벨 에디터 뷰를 토글할 수 있습니다.
아래 GIF처럼 두 번째 방을 내려다보는 위치에 카메라를 파일럿합니다.
완성된 카메라 씬 구성은 아래 이미지처럼 스태틱 카메라가 새 방을 내려다보고, 원본 카메라는 삼인칭 액터를 따르는 모습일 것입니다.
오버레이 트리거 액터 생성
이 예시에서 트리거 액터는 플레이어의 카메라 시점과 스태틱 카메라 시점 사이의 트랜지션을 관리하는 기능을 합니다. 플레이어가 박스 컴포넌트 볼륨 바운드와 겹쳐지면 두 시점이 블렌딩을 거쳐 트랜지션됩니다.
Using the C++ Class Wizard, create a new Actor class named BlendTriggerVolume.
Navigate to your
BlendTriggerVolume.hfile, and declare the following code in your class definition.C++protected: //Collision Bounds of the Actor Volume UPROPERTY(EditAnywhere, BlueprintReadWrite) class UBoxComponent* OverlapVolume; //Camera Actor which the Actor Volume blends to UPROPERTY(EditAnywhere, BlueprintReadWrite) TSubclassOf<ACameraActor> CameraToFind;Next, navigate to your
BlendTriggerVolume.cppfile to set up your constructor and box component overlap methods. Declare the following include class libraries.C++`#include "Components/BoxComponent.h"` `#include "StaticCamerasCharacter.h"` `#include "Camera/CameraActor.h"` `#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"`In the constructor ABlendTriggerVolume::ABlendTriggerVolume, declare the following code.
C++ABlendTriggerVolume::ABlendTriggerVolume() { //Create box component default components OverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("CameraProximityVolume")); //Set the box component attachment to the root component. OverlapVolume->SetupAttachment(RootComponent); }Next, implement your
NotifyActorBeginOverlapandNotifyActorEndOverlapclass methods:C++void ABlendTriggerVolume::NotifyActorBeginOverlap(AActor* OtherActor){ //Cast check to see if overlapped Actor is Third Person Player Character if (AStaticCamerasCharacter* PlayerCharacterCheck = Cast<AStaticCamerasCharacter>(OtherActor)) { //Cast to Player Character's PlayerController if (APlayerController* PlayerCharacterController = Cast<APlayerController>(PlayerCharacterCheck->GetController())) {Compile your code.
Finished Code
BlendTriggerVolume.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "BlendTriggerVolume.generated.h"
UCLASS()
class STATICCAMERAS_API ABlendTriggerVolume : public AActor
{
GENERATED_BODY()
BlendTriggerVolume.cpp
#include "BlendTriggerVolume.h"
#include "Components/BoxComponent.h"
#include "StaticCamerasCharacter.h"
#include "Camera/CameraActor.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
// Sets default values
ABlendTriggerVolume::ABlendTriggerVolume()
{
Setting up the Overlap Trigger Actor
Now that you have created your overlap Actor, you will need to place it into the level and set up its bounds.
Begin by navigating to your C++ Classes folder, right-click on your BlendTriggerVolume class, select Create Blueprint Class based on BlendTriggerVolume, then name your Blueprint Actor BP_BlendTriggerVolume.
From the class defaults, navigate to Camera To Find in the Details panel, open the drop down menu, then select BP_ExampleCameraActor.
Optionally, you can change the default blend time for this Blueprint without having to go back into the source code, or affecting other Blueprints with the same inherited parent class.
Compile and Save.
From the Content Browser, drag an instance of BP_BlendTriggerVolume into the level.
Move the BP_BlendTriggerVolume into the room with your BP_ExampleCameraActor, and from the Details panel select the box component. Navigate to the Shape category and modify the Box Extent X, Y, and Z values so the volume will fit your room.
From the Main Editor View, click the Play button to play in the Editor.
최종 결과
게임을 시작하면 플레이어는 WASD를 사용하여 캐릭터의 무브먼트를 제어합니다. 카메라 뷰가 BP_BlendTriggerVolume과 겹쳐지면 앞서 생성하여 레벨에 배치한 카메라 액터(Camera Actor)에 할당되며, 플레이어가 제어하는 캐릭터의 조감도 샷으로 뷰가 전환됩니다.
뷰가 레터박스 처리된 것을 볼 수 있습니다. 카메라 액터의 디테일(Details) 패널에서 종횡비 제한(Constrain Aspect Ratio) 옵션을 체크 해제하여 비활성화할 수 있습니다.