C++ Replication doesnt show on server

So ive implemented the following code:

in my header file i have:

	UPROPERTY(Replicated,BlueprintReadOnly, Category = "EFC|LookAxis")
	float aimDirection;

       virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

And the implementation of this:

void AEFCPlayerCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(AEFCPlayerCharacter, aimDirection);
}

Then in my constructor i have:

SetReplicates(true);

And then im using that in my AnimBluePrint:

image

Now my client is able to see this change however my server is unable to see the client doing it so what have i done wrong?

How are you sending the change in aimdirection to the server from the client playercontroller?

Replication = Server changes data → Client receives updated data. If you are changing a replicated value on client side, nothing will happen.

1 Like

Unless you are custom rotation shenanigans, the engine already replicates aim.
Use GetBaseAimRotation to access it (or just the pitch).
Example :


(when doing this) https://docs.unrealengine.com/4.27/en-US/AnimatingObjects/SkeletalMeshAnimation/AimOffset/

If you use custom rotation like fixed rotation rates (tank turret etc.) then yes you might have to roll your own method, although I’d probably still recommend to avoid replicating values every tick. Considering the player’s aim is already replicated, you could just calculate your custom rotations locally on every machine.

If you really need to replicate, as others pointed out you need to use client->server replicated function call (prefer unreliable if on Tick), because variables only replicate server->client.

The server should be determining its own aim direction on the auth proxy. It will handle replicating the result out to simulated proxies on other clients. You just need to ensure the server runs the function that calcs Aim Direction just as your Autonomous Proxy does.