AnimInstance variable replication

Hello there.

I wonder if is this possible to have replicated variables in classes that derives from AnimInstance?

Here’s what I have so far (it doesn’t work tho :/)

SoldierAnimInstance.h

UCLASS()
class THUNDER2305_API USoldierAnimInstance : public UAnimInstance
{
	GENERATED_BODY()

public:

	UPROPERTY(Replicated)
	float CachedYaw;

	virtual void NativeUpdateAnimation(float DeltaSeconds) override;
}

SoldierAnimInstance.cpp

USoldierAnimInstance::USoldierAnimInstance()
{	
	CachedYaw = -1.f;
}

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

	DOREPLIFETIME(USoldierAnimInstance, CachedYaw);
}

void USoldierAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
	if (TryGetPawnOwner() && TryGetPawnOwner()->Role >= ROLE_Authority)
	{
		CachedYaw = 5.f;
	}
	
	Super::NativeUpdateAnimation(DeltaSeconds);
}

Any ideas why this doesn’t work and how to fix that? Btw. UE4.8.1 here.

Thanks in advance.

I think I’ve found an answer here. :confused:

The first class in the UObject class hierarchy that implements replication is AActor. All game relevant objects that you wish to be shared between server and clients have to be Actors.

UAnimInstance is a subclass of UObject