OpenLevelÀ» ÀÌ¿ëÇÏ¸é ¸Ê ·Îµù½Ã gamemode¸¦ º¯°æ ÇÒ¼ö ÀÖ´Ù. ´Ù¸¥ ºÐÀÇ ¿¹Á¦¸¦ ÀÌ¿ëÇؼ Äڵ带 Á¶±Ý ¼öÁ¤ÇÑ´Ù. º£¸£´ÔÀÇ ¿¹Á¦¸¦ ÀÌ¿ëÇÑ´Ù. º£¸£ÀÇ ÇÁ·Î±×·¡¹Ö : ´Ù¸¥ ·¹º§·Î À̵¿Çϱâ https://wergia.tistory.com/152 ÀÌ ¿¹Á¦´Â ƯÁ¤ÇÑ °ø°£¿¡ µé¾î°¡¸é OpenLevelÀ» ÀÌ¿ëÇØ ´Ù¸¥ ¸ÊÀ» ·ÎµùÇÑ´Ù. À§ÀÇ ¿¹Á¦¿¡¼ °ÔÀÓ¸ðµå¸¦ º¯°æÇϱâ À§ÇØ ¸î°¡Áö ÀÛ¾÷À» ÇÑ´Ù. 1. À̵¿ ÇÒ·Á´Â ¸Ê¿¡ »ç¿ëÇÒ C++ °ÔÀÓ ¸ðµå AMyTestGameMode Ŭ·¡½º¸¦ ¸¸µç´Ù. Ŭ·¡½º¸¦ ¸¸µé°í »ý¼ºÀÚ¿Í Tick ÇÔ¼ö¸¦ Ãß°¡ ÇÑ´Ù. Tick ÇÔ¼ö¸¦ È£Ãâ Çϱâ À§ÇØ »ý¼ºÀÚ¿¡¼ ´ÙÀ½°ú °°ÀÌ ¼³Á¤ÇÑ´Ù. PrimaryActorTick.bCanEverTick = true; Tick ÇÔ¼ö¿¡¼ °ÔÀÓ¸ðµå°¡ ¹Ù²ïÁö ¾Ë±â À§ÇØ È¸é¿¡ ¹®ÀÚ¿À» Ãâ·ÂÇÑ´Ù. GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Red, TEXT(" Second Map")); MyTestGameMode.h #include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h" #include "MyTestGameMode.generated.h" UCLASS() class LEVELOPENTEST_API AMyTestGameMode : public AGameModeBase { GENERATED_BODY() public: AMyTestGameMode(); public: virtual void Tick(float DeltaTime) override; }; MyTestGameMode.cpp #include "MyTestGameMode.h"
AMyTestGameMode::AMyTestGameMode() { PrimaryActorTick.bCanEverTick = true; } void AMyTestGameMode::Tick(float DeltaTime) { Super::Tick(DeltaTime); GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Red, TEXT(" Second Map")); } 2. AMyTestGameMode¸¦ ºÎ¸ð Ŭ·¡½º·Î ÇÏ´Â ºí·çÇÁ¸°Æ®¸¦ ¸¸µç´Ù. ÀÌ ºí·çÇÁ¸°Æ®´Â OpenLevel ÇÔ¼ö È£Ãâ½Ã¿¡ »ç¿ë ÇÑ´Ù. º°µµÀÇ gamemodeÀÇ Classes °ªÀ» »ç¿ë ÇÑ´Ù¸é ´Ù¸¥ gamemode ºí·çÇÁ¸°Æ®¿¡¼ º¹»çÇÑ´Ù. ¿©±â¼´Â ±âº» °ªÀ» »ç¿ëÇÏ°í ÀÖ´Ù. 3. OpenLevele ÇÔ¼ö 3¹ø° ÀÎÀÚ¿¡ °ÔÀÓ¸ðµå¸¦ ÁöÁ¤ÇÑ´Ù. °ÔÀÓ ¸ðµå ºí·çÇÁ¸°Æ® À̸§¿¡ "_C"¸¦ ºÙÀδÙ. Game=/Game/blueprint/BP_TestMode.BP_TestMode_C void ALevelTransferVolume::NotifyActorBeginOverlap(AActor * OtherActor)
{ APawn* Pawn = Cast<APawn>(OtherActor); if (Pawn != nullptr) { UGameplayStatics::OpenLevel(this, FName(*TransferLevelName), true, ((FString)("Game=/Game/blueprint/BP_TestMode.BP_TestMode_C"))); } } C++ÀÌ ¾Æ´Ñ ºí·çÇÁ¸°Æ®¿¡¼ OpenLevelÀ» ½ÇÇà ÇÒ¶§´Â ´ÙÀ½°ú °°ÀÌ ÇØ¾ß ÇÏ´Â°Í °°´Ù. ÀÌ°Ç ½ÇÁ¦·Î Å×½ºÆ® Çغ¸Áø ¾Ê¾ÒÀ½. "?Game=/Game/blueprint/BP_TestMode.BP_TestMode_C" ´Ù¿î·Îµå) LevelTransferVolume.h LevelTransferVolume.cpp MyTestGameMode.h MyTestGameMode.cpp LevelOpenTest.zip |