So, I’ve got an actor which needs a dynamic scale at runtime. That scale is set just after it is constructed on the server. The scale does not get replicated to the client.
I added the following to try and fix that (in the header):
UPROPERTY( Category = "Barrage | Actor | Building", ReplicatedUsing = OnRep_vActorScaleReplication, EditInstanceOnly )
FVector vActorScaleReplication;
UFUNCTION()
virtual void OnRep_vActorScaleReplication();
And in the code:
ABCBuildingActor::ABCBuildingActor(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
bAlwaysRelevant = true;
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bTickEvenWhenPaused = false;
SetActorTickEnabled( true );
vActorScaleReplication = FVector( 1.f, 1.f, 1.f );
}
void ABCBuildingActor::TickActor( float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction )
{
Super::TickActor( DeltaTime, TickType, ThisTickFunction );
if ( !HasServer() )
{
SetActorRelativeScale3D( vActorScaleReplication );
}
}
void ABCBuildingActor::OnRep_vActorScaleReplication()
{
BCLogUO( "Vector: %f, %f, %f", ExpandV3( vActorScaleReplication ) );
}
Ignore the HasServer and BCLogUO, they are macros (which function perfectly). The breakpoint in the OnRep function is never called. The vActorScaleReplication variable is set on the server. It is never replicated to the client, despite me looking directly at the actor that has been replicated (it is always 1.f, 1.f, 1.f.) I added the always relevant thing in case it wasn’t I know using the tick function is inefficient, but it’s just a stop gap for a proper solution.
I haven’t included the code in the server that sets the variable, but it is set (breakpoints and the details panel confirm it is not 1.f, 1.f, 1.f.)
I hvae no idea what’s going on, or why it’s not replicating.