KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
OutBoxTeleportTrigger.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
3
5
6#include "ATeleportOut.h"
7#include "Food.h"
8#include "GameLogging.h"
9#include "luggage.h"
10#include "LuggageManager.h"
11#include "Components/BoxComponent.h"
12#include "Components/SceneComponent.h"
13#include "Kismet/GameplayStatics.h"
14
15
17{
18 PrimaryActorTick.bCanEverTick = false;
19
20 RootComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootComp"));
21 SetRootComponent(RootComp);
22
23 BoxComp = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComp"));
24 BoxComp->SetupAttachment(GetRootComponent());
25 BoxComp->SetBoxExtent(FVector(50, 50, 50));
26 BoxComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
27 BoxComp->SetCollisionObjectType(ECollisionChannel::ECC_WorldStatic);
28 BoxComp->SetCollisionResponseToAllChannels(ECR_Overlap);
29
30 CubeMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CubeMesh"));
31 ConstructorHelpers::FObjectFinder<UStaticMesh> cubeMeshRef(TEXT("/Script/Engine.StaticMesh'/Engine/BasicShapes/Cube.Cube'"));
32 if (cubeMeshRef.Succeeded())
33 {
34 CubeMesh->SetStaticMesh(cubeMeshRef.Object);
35 }
36 CubeMesh->SetupAttachment(GetRootComponent());
37 CubeMesh->SetCollisionProfileName(TEXT("NoCollision"));
38 CubeMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
39 CubeMesh->SetCollisionResponseToAllChannels(ECR_Ignore);
40 CubeMesh->SetVisibility(false);
41}
42
44{
45 Super::BeginPlay();
46
47 AActor* luggageManager = UGameplayStatics::GetActorOfClass(GetWorld(), ALuggageManager::StaticClass());
48 LuggageRespawnPoint = luggageManager->GetActorLocation();
49
50 AActor* teleportOut = UGameplayStatics::GetActorOfClass(GetWorld(), ATeleportOut::StaticClass());
51 FoodRespawnPoint = teleportOut->GetActorLocation();
52
53 BoxComp->OnComponentBeginOverlap.AddDynamic(this, &AOutBoxTeleportTrigger::OnBoxBeginOverlap);
54}
55
56void AOutBoxTeleportTrigger::OnBoxBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
57 UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
58{
59 if (Cast<Aluggage>(OtherActor))
60 {
61 OtherActor->SetActorLocation(LuggageRespawnPoint, false, nullptr, ETeleportType::TeleportPhysics);
62 }
63 else if (Cast<AFood>(OtherActor))
64 {
65 OtherActor->SetActorLocation(FoodRespawnPoint, false, nullptr, ETeleportType::TeleportPhysics);
66 }
67}
68
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
TObjectPtr< class UBoxComponent > BoxComp
void OnBoxBeginOverlap(UPrimitiveComponent *OverlappedComp, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
TObjectPtr< class UStaticMeshComponent > CubeMesh
virtual void BeginPlay() override
TObjectPtr< class USceneComponent > RootComp