Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions Source/DISRuntime/Private/DISGameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,6 @@ void ADISGameManager::BeginPlay()
}
}

void ADISGameManager::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

for (std::pair<FEntityID, AActor*> DisEntity : RawDISActorMappings)
{
if (IsValid(DisEntity.second))
{
UDISReceiveComponent* DISComponent = IDISInterface::Execute_GetActorDISReceiveComponent(DisEntity.second);

if (DISComponent)
{
DISComponent->DoDeadReckoning(DeltaTime);
}
else
{
UE_LOG(LogDISGameManager, Warning, TEXT("Cannot find DISComponent on entity %s"), *DisEntity.second->GetName())
}
}
else
{
UE_LOG(LogDISGameManager, Error, TEXT("Encountered null reference within RawDISActorMapping! Check C++ side usage of RawDISActorMapping to verify using properly!"));
}
}
}

void ADISGameManager::HandleOnDISEntityDestroyed(AActor* DestroyedActor)
{
bool anyRemoved = false;
Expand Down
21 changes: 13 additions & 8 deletions Source/DISRuntime/Private/DISReceiveComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ UDISReceiveComponent::UDISReceiveComponent()
{
bWantsInitializeComponent = true;
PrimaryComponentTick.bCanEverTick = true;
PrimaryComponentTick.bStartWithTickEnabled = false;
PrimaryComponentTick.bStartWithTickEnabled = true;
// The PrePhysics tick group ensures that there is no jittering with camera using SpringArms or equivalent
PrimaryComponentTick.TickGroup = ETickingGroup::TG_PrePhysics;
}

void UDISReceiveComponent::InitializeComponent()
Expand Down Expand Up @@ -57,6 +59,8 @@ void UDISReceiveComponent::BeginPlay()
void UDISReceiveComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
DoDeadReckoning(DeltaTime);
ApplyToOwnerIfActivated(MostRecentDeadReckonedEntityStatePDU);
}

void UDISReceiveComponent::HandleEntityStatePDU(FEntityStatePDU NewEntityStatePDU)
Expand All @@ -75,10 +79,9 @@ void UDISReceiveComponent::HandleEntityStatePDU(FEntityStatePDU NewEntityStatePD
EntityForceID = NewEntityStatePDU.ForceID;
EntityMarking = NewEntityStatePDU.Marking;

ApplyToOwnerIfActivated(NewEntityStatePDU);
OnReceivedEntityStatePDU.Broadcast(NewEntityStatePDU);

if (!PerformDeadReckoning)
if (!PerformDeadReckoning && !ApplyToOwner)
{
GroundClamping();
}
Expand All @@ -100,7 +103,7 @@ void UDISReceiveComponent::HandleEntityStateUpdatePDU(FEntityStateUpdatePDU NewE
ApplyToOwnerIfActivated(MostRecentEntityStatePDU);
OnReceivedEntityStateUpdatePDU.Broadcast(NewEntityStateUpdatePDU);

if (!PerformDeadReckoning)
if (!PerformDeadReckoning && !ApplyToOwner)
{
GroundClamping();
}
Expand Down Expand Up @@ -193,12 +196,13 @@ void UDISReceiveComponent::DoDeadReckoning(float DeltaTime)
MostRecentDeadReckonedEntityStatePDU = SmoothDeadReckoning(MostRecentDeadReckonedEntityStatePDU);
}

ApplyToOwnerIfActivated(MostRecentDeadReckonedEntityStatePDU);
OnDeadReckoningUpdate.Broadcast(MostRecentDeadReckonedEntityStatePDU);
}

//Perform ground clamping last
GroundClamping();
if (!ApplyToOwner)
{
//Perform ground clamping last
GroundClamping();
}
}
}

Expand Down Expand Up @@ -282,4 +286,5 @@ void UDISReceiveComponent::ApplyToOwnerIfActivated(FEntityStatePDU const& StateP
FRotator newRotation;
UDIS_BPFL::GetUnrealLocationAndOrientationFromEntityStatePdu(StatePDU, GeoReferencingSystem, newLocation, newRotation);
GetOwner()->SetActorLocationAndRotation(newLocation, newRotation);
GroundClamping();
}
1 change: 0 additions & 1 deletion Source/DISRuntime/Public/DISGameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class DISRUNTIME_API ADISGameManager : public AInfo

protected:
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;

UFUNCTION()
void HandleOnDISEntityDestroyed(AActor* DestroyedActor);
Expand Down