Added tick control on sensor for sensor_tick attribute

This commit is contained in:
doterop 2021-01-20 19:26:25 +01:00
parent fa2cde9ace
commit 2317e35f98
2 changed files with 16 additions and 1 deletions

View File

@ -24,7 +24,7 @@ void ASensor::BeginPlay()
{
Super::BeginPlay();
OnPostTickDelegate = FWorldDelegates::OnWorldPostActorTick.AddUObject(
this, &ASensor::PostPhysTick);
this, &ASensor::PostPhysTickInternal);
}
void ASensor::Set(const FActorDescription &Description)
@ -41,6 +41,7 @@ void ASensor::Set(const FActorDescription &Description)
void ASensor::Tick(const float DeltaTime)
{
Super::Tick(DeltaTime);
ReadyToTick = true;
PrePhysTick(DeltaTime);
}
@ -77,3 +78,12 @@ void ASensor::EndPlay(EEndPlayReason::Type EndPlayReason)
FWorldDelegates::OnWorldPostActorTick.Remove(OnPostTickDelegate);
}
void ASensor::PostPhysTickInternal(UWorld *World, ELevelTick TickType, float DeltaSeconds)
{
if(ReadyToTick)
{
PostPhysTick(World, TickType, DeltaSeconds);
ReadyToTick = false;
}
}

View File

@ -101,9 +101,14 @@ protected:
private:
void PostPhysTickInternal(UWorld *World, ELevelTick TickType, float DeltaSeconds);
FDataStream Stream;
FDelegateHandle OnPostTickDelegate;
const UCarlaEpisode *Episode = nullptr;
/// Allows the sensor to tick with the tick rate from UE4.
bool ReadyToTick = false;
};