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.