-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelTransitionVolume.cpp
50 lines (38 loc) · 1.44 KB
/
LevelTransitionVolume.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Fill out your copyright notice in the Description page of Project Settings.
#include "LevelTransitionVolume.h"
#include "Components/BoxComponent.h"
#include "Components/BillboardComponent.h"
#include "MainCharacter.h"
// Sets default values
ALevelTransitionVolume::ALevelTransitionVolume()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
TransitionVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("TransitionVolume"));
RootComponent = TransitionVolume;
Billboard = CreateDefaultSubobject<UBillboardComponent>(TEXT("Billboard"));
Billboard->SetupAttachment(GetRootComponent());
TransitionLevelName = "SunTemple";
}
// Called when the game starts or when spawned
void ALevelTransitionVolume::BeginPlay()
{
Super::BeginPlay();
TransitionVolume->OnComponentBeginOverlap.AddDynamic(this, &ALevelTransitionVolume::OnOverlapBegin);
}
// Called every frame
void ALevelTransitionVolume::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALevelTransitionVolume::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor)
{
AMainCharacter* Main = Cast<AMainCharacter>(OtherActor);
if (Main)
{
Main->SwitchLevel(TransitionLevelName);
}
}
}