Created
June 4, 2020 00:19
-
-
Save thejustinwalsh/bd7c4edebc57ecbdecb5bb40665578a8 to your computer and use it in GitHub Desktop.
UE4 FixedCustomTimeStep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FixedCustomTimeStep.h" | |
bool UFixedCustomTimeStep::Initialize(UEngine* InEngine) | |
{ | |
check(InEngine); | |
State = ECustomTimeStepSynchronizationState::Synchronized; | |
return true; | |
} | |
void UFixedCustomTimeStep::Shutdown(UEngine* InEngine) | |
{ | |
check(InEngine); | |
State = ECustomTimeStepSynchronizationState::Closed; | |
} | |
bool UFixedCustomTimeStep::UpdateTimeStep(UEngine* InEngine) | |
{ | |
if (State == ECustomTimeStepSynchronizationState::Synchronized) | |
{ | |
WaitForFixedFrameRate(); | |
return false; | |
} | |
return true; | |
} | |
FFrameRate UFixedCustomTimeStep::GetFixedFrameRate() const | |
{ | |
static const FFrameRate FrameRate(60, 1); | |
return FrameRate; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "CoreMinimal.h" | |
#include "FixedFrameRateCustomTimeStep.h" | |
#include "FixedCustomTimeStep.generated.h" | |
/** | |
* | |
*/ | |
UCLASS() | |
class BULLETSFTW_API UFixedCustomTimeStep : public UFixedFrameRateCustomTimeStep | |
{ | |
GENERATED_BODY() | |
public: | |
virtual bool Initialize(UEngine* InEngine) override; | |
virtual void Shutdown(UEngine* InEngine) override; | |
virtual bool UpdateTimeStep(UEngine* InEngine) override; | |
virtual ECustomTimeStepSynchronizationState GetSynchronizationState() const override { return State; } | |
virtual FFrameRate GetFixedFrameRate() const override; | |
private: | |
ECustomTimeStepSynchronizationState State = ECustomTimeStepSynchronizationState::Closed; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"AdditionalDependencies": [ | |
..., | |
"TimeManagement" | |
] | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment