Skip to content

Instantly share code, notes, and snippets.

@thejustinwalsh
Created June 4, 2020 00:19
Show Gist options
  • Save thejustinwalsh/bd7c4edebc57ecbdecb5bb40665578a8 to your computer and use it in GitHub Desktop.
Save thejustinwalsh/bd7c4edebc57ecbdecb5bb40665578a8 to your computer and use it in GitHub Desktop.
UE4 FixedCustomTimeStep
#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;
}
#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;
};
...
"AdditionalDependencies": [
...,
"TimeManagement"
]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment