hello.
i am creating a simple multiplayer “game” for the sake of learning. i created a character like so:
class GAMEPROTOTYPE_API Acpp_BaseGameCharacter : public AGamePrototypeCharacter
{
Acpp_BaseGameCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
void TestSwipe();
UFUNCTION(Server, WithValidation, Reliable)
void ServerTestSwipe();
virtual void BeginPlay() override;
}
and in the cpp i added a custom movement component which is empty
Acpp_BaseGameCharacter::Acpp_BaseGameCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<Ucpp_ExtendedMovementComponent>(ACharacter::CharacterMovementComponentName))
and everything worked fine.
But after adding the following line :
UPROPERTY(Replicated,BlueprintReadOnly)
int32 Health=10000;
UPROPERTY(Replicated)
int32 Mana;
void Acpp_BaseGameCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
DOREPLIFETIME(Acpp_BaseGameCharacter, Health);
DOREPLIFETIME(Acpp_BaseGameCharacter, Mana);
}
the client stopped receiving updates on servers character (location, movement and animations) and also could not be controlled.
i tried to add bReplicates=true wherever i could thing of.