Remove Property from Replication (Location)

Hey
Is there a way to remove a property from replication?
Im moving (Lerping with a Timeline) “thousands” of actors at once. On the Server all Objects move very smooth but on clientside they are kind of laggy. so my idea was to replicate the “move to” function instead of replicating the Location. is there any way to do this?

#include "UnrealNetwork.h"

void AMyActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(AMyActor, SomeProperty);
}

is there a method like "REMOVE_DROPLIFETIME(AMyActor, Location); or something? Everything i can find is removing the replication comepletely, but thats not what i want.

Or is there maybe a better solution for this?

Too late for the OP, but maybe it’ll help someone.

One solution is in AActor::PreReplication you can call DOREPLIFETIME_ACTIVE_OVERRIDE(ABaseActor, SomeProperty, false)

Another solution is. if you look at the definition of DOREPLIFETIME_CONDITION:

#define DOREPLIFETIME_CONDITION(c,v,cond) \
{ \
	static UProperty* sp##v = GetReplicatedProperty(StaticClass(), c::StaticClass(),GET_MEMBER_NAME_CHECKED(c,v)); \
	for ( int32 i = 0; i < sp##v->ArrayDim; i++ )										\
	{																					\
		OutLifetimeProps.AddUnique( FLifetimeProperty( sp##v->RepIndex + i, cond ) );	\
	}																					\
}

So you could manually remove the property from OutLifetimeProps. E.g:

Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	static UProperty* const replicated_property = GetReplicatedProperty(StaticClass(), ABaseActor::StaticClass(), TEXT("SomeProperty"));
	const int32 min_rep_index = replicated_property ->RepIndex;
	const int32 max_rep_index = min_rep_index + replicated_property ->ArrayDim;

	OutLifetimeProps.RemoveAll([min_rep_index, max_rep_index](const FLifetimeProperty& prop)
	{
		return prop.RepIndex >= min_rep_index && prop.RepIndex < max_rep_index;
	});

The advantage of doing it in GetLifetimeReplicatedProps is that it only gets called once, whereas PreReplication is called every time that actor is replicated.

use the following inside GetLifetimeReplicatedProps

DISABLE_REPLICATED_PROPERTY(AYourActor, urPropery);

or if its a private propery, like bHidden for example:

DISABLE_REPLICATED_PRIVATE_PROPERTY(AYourActor, bHidden);

im not sure when exactly they added this

5 Likes