More functionality moved to C++, allowing BugPlacerPawn to properly initialise and destroy itself.
This commit is contained in:
parent
dba5c7712a
commit
4aadcee90c
Binary file not shown.
@ -3,7 +3,9 @@
|
|||||||
#include "BugPlacerPawn.h"
|
#include "BugPlacerPawn.h"
|
||||||
|
|
||||||
#include "Components/SphereComponent.h"
|
#include "Components/SphereComponent.h"
|
||||||
|
#include "GameFramework/Character.h"
|
||||||
#include "GameFramework/FloatingPawnMovement.h"
|
#include "GameFramework/FloatingPawnMovement.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
|
||||||
ABugPlacerPawn::ABugPlacerPawn()
|
ABugPlacerPawn::ABugPlacerPawn()
|
||||||
@ -27,10 +29,14 @@ ABugPlacerPawn::ABugPlacerPawn()
|
|||||||
|
|
||||||
void ABugPlacerPawn::BeginPlay()
|
void ABugPlacerPawn::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
this->GetWorldSettings()->SetTimeDilation(this->GetWorldSettings()->MinGlobalTimeDilation);
|
this->GetWorldSettings()->SetTimeDilation(this->GetWorldSettings()->MinGlobalTimeDilation);
|
||||||
this->CustomTimeDilation = 1.0f / this->GetWorldSettings()->MinGlobalTimeDilation;
|
this->CustomTimeDilation = 1.0f / this->GetWorldSettings()->MinGlobalTimeDilation;
|
||||||
|
|
||||||
|
this->OriginalPlayer = UGameplayStatics::GetPlayerCharacter(this, 0);
|
||||||
|
|
||||||
|
this->Activate();
|
||||||
|
|
||||||
|
Super::BeginPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABugPlacerPawn::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
void ABugPlacerPawn::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||||
@ -40,3 +46,18 @@ void ABugPlacerPawn::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|||||||
|
|
||||||
Super::EndPlay(EndPlayReason);
|
Super::EndPlay(EndPlayReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ABugPlacerPawn::Activate()
|
||||||
|
{
|
||||||
|
this->SavedMaxSpeed = this->PawnMovement->GetMaxSpeed();
|
||||||
|
|
||||||
|
UGameplayStatics::GetPlayerController(this, 0)->Possess(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABugPlacerPawn::Deactivate()
|
||||||
|
{
|
||||||
|
UGameplayStatics::GetPlayerController(this, 0)->Possess(this->OriginalPlayer);
|
||||||
|
|
||||||
|
this->Destroy();
|
||||||
|
}
|
||||||
|
|||||||
@ -19,10 +19,22 @@ public:
|
|||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void Activate();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void Deactivate();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
float SavedMaxSpeed = 0.0f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true"))
|
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<class USphereComponent> SphereComponent;
|
TObjectPtr<class USphereComponent> SphereComponent;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true"))
|
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<class UFloatingPawnMovement> PawnMovement;
|
TObjectPtr<class UFloatingPawnMovement> PawnMovement;
|
||||||
|
|
||||||
|
TObjectPtr<class ACharacter> OriginalPlayer;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user