diff --git a/Content/BP_BugPlacerPawn.uasset b/Content/BP_BugPlacerPawn.uasset index d3b9d68..e5c94bd 100644 Binary files a/Content/BP_BugPlacerPawn.uasset and b/Content/BP_BugPlacerPawn.uasset differ diff --git a/Source/Unrealzilla/Private/BugPlacerPawn.cpp b/Source/Unrealzilla/Private/BugPlacerPawn.cpp index cba0a63..7e60408 100644 --- a/Source/Unrealzilla/Private/BugPlacerPawn.cpp +++ b/Source/Unrealzilla/Private/BugPlacerPawn.cpp @@ -10,6 +10,7 @@ #include "Components/SphereComponent.h" #include "GameFramework/Character.h" #include "GameFramework/FloatingPawnMovement.h" +#include "HAL/IConsoleManager.h" #include "Kismet/GameplayStatics.h" @@ -46,9 +47,6 @@ ABugPlacerPawn::ABugPlacerPawn() void ABugPlacerPawn::BeginPlay() { - this->GetWorldSettings()->SetTimeDilation(this->GetWorldSettings()->MinGlobalTimeDilation); - this->CustomTimeDilation = 1.0f / this->GetWorldSettings()->MinGlobalTimeDilation; - this->OriginalPlayer = UGameplayStatics::GetPlayerCharacter(this, 0); this->Activate(); @@ -56,15 +54,7 @@ void ABugPlacerPawn::BeginPlay() Super::BeginPlay(); } -void ABugPlacerPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) -{ - this->CustomTimeDilation = 1.0f; - this->GetWorldSettings()->SetTimeDilation(1.0f); - - Super::EndPlay(EndPlayReason); -} - -void ABugPlacerPawn::Tick(float DeltaSeconds) +void ABugPlacerPawn::TraceTimerElapsed() { const UWorld *World = this->GetWorld(); @@ -140,10 +130,15 @@ void ABugPlacerPawn::Activate() this->SavedMaxSpeed = this->PawnMovement->GetMaxSpeed(); UGameplayStatics::GetPlayerController(this, 0)->Possess(this); + + float TraceInterval = this->GetActorTickInterval() > 0.0f ? this->GetActorTickInterval() : 1.0f / 30.0f; + this->GetWorldTimerManager().SetTimer(this->TraceTimerHandle, this, &ABugPlacerPawn::TraceTimerElapsed, TraceInterval, true); } void ABugPlacerPawn::Deactivate() { + this->GetWorldTimerManager().ClearAllTimersForObject(this); + UGameplayStatics::GetPlayerController(this, 0)->Possess(this->OriginalPlayer); this->Destroy(); diff --git a/Source/Unrealzilla/Public/BugPlacerPawn.h b/Source/Unrealzilla/Public/BugPlacerPawn.h index ed3db1d..014361d 100644 --- a/Source/Unrealzilla/Public/BugPlacerPawn.h +++ b/Source/Unrealzilla/Public/BugPlacerPawn.h @@ -17,9 +17,6 @@ public: ABugPlacerPawn(); virtual void BeginPlay() override; - virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; - - virtual void Tick(float DeltaSeconds) override; UFUNCTION(BlueprintCallable) void Activate(); @@ -72,6 +69,8 @@ protected: float SavedMaxSpeed = 0.0f; private: + void TraceTimerElapsed(); + uint8 bArbitraryPlacement : 1; uint8 bCurrentTraceHit : 1; @@ -79,4 +78,8 @@ private: TObjectPtr BugMarker; TObjectPtr ExitingBugPlacementScreen; + + //UPROPERTY(EditDefaultsOnly, meta=(UIMin="0.0", UIMax="0.25")) + // float TraceTimerDelay = 0.05f; + FTimerHandle TraceTimerHandle; };