Create LevelEndTriggerVolume
This commit is contained in:
parent
ee42aabc2a
commit
48bb8f9ef6
|
@ -0,0 +1,38 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "LevelEndTriggerVolume.h"
|
||||||
|
|
||||||
|
#include <Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
|
#include "PlayerCharacter.h"
|
||||||
|
|
||||||
|
void ALevelEndTriggerVolume::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
// OnActorBeginOverlap.AddDynamic(this, &ALevelEndTriggerVolume::OnOverlapBegin);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ALevelEndTriggerVolume::ALevelEndTriggerVolume()
|
||||||
|
{
|
||||||
|
GetCollisionComponent()->OnComponentBeginOverlap.AddDynamic(this, &ALevelEndTriggerVolume::OnOverlapBegin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALevelEndTriggerVolume::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||||
|
const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
// TODO: Add extra functionality!
|
||||||
|
if (Cast<APlayerCharacter>(OtherActor))
|
||||||
|
{
|
||||||
|
GetCollisionComponent()->OnComponentBeginOverlap.Clear();
|
||||||
|
|
||||||
|
if (!NextGameLevel.IsNull())
|
||||||
|
{
|
||||||
|
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NextGameLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->Destroy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Engine/TriggerBox.h"
|
||||||
|
#include "LevelEndTriggerVolume.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API ALevelEndTriggerVolume : public ATriggerBox
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ALevelEndTriggerVolume();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||||
|
const FHitResult& SweepResult);
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
TSoftObjectPtr<UWorld> NextGameLevel;
|
||||||
|
};
|
Loading…
Reference in New Issue