Movement replication

Hey there,

I got a simple question about character movement being replicated over a network.
I created a custom character movement component and added it inside the constructor like this:

// Sets default values
AZA_PlayerCharacter::AZA_PlayerCharacter(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer.SetDefaultSubobjectClass<UZA_PlayerMovement(ACharacter::CharacterMovementComponentName))
{
// Code here ...
}

The playercharacter class inherites from an AZA_AbstractCharacter because I also have an enemy class and he will inherit from this class too. The constructor of this class looks like this:

// Sets default values
AZA_AbstractCharacter::AZA_AbstractCharacter(const FObjectInitializer& ObjectInitializer) 
: Super(ObjectInitializer)
{
// Code here ...
}

I also set the booleans Replicates and Replicate Movement to true inside my character.
And the last thing I did was creating some server methods for all my movement.
For example:

void UZA_CharacterMovement::SetSprint(bool bNewSprint)
{
	_bIsSprinting = bNewSprint;

	//We stop aiming when we are sprinting
	if (_bIsSprinting)
		StopAim();

	//OrientRotation to movement is the opposite of the sprinting variable
	bOrientRotationToMovement = !_bIsSprinting;

	//Let the character only rotate over the yaw axis
	GetOwningCharacter()->bUseControllerRotationYaw = _bIsSprinting;

	MaxWalkSpeed = bNewSprint ? _doubleMaxWalkSpeed : _defaultMaxWalkSpeed;

	if (GetOwningCharacter()->Role < ROLE_Authority)
		ServerSetSprint(bNewSprint);
}

Now this method gets fired from the character controller, because according to the unreal documentation:
PlayerControllers are used by human players to control Pawns.
In other words when I press the right mouse button the controller fires a method like this:

void AZA_PlayerController::StartSprint()
{
	if (GetOwningPlayerMovement())
		GetOwningPlayerMovement()->StartSprint();
}

And this method will tell the movementcomponent that the player wants to sprint and set the sprinting boolean to true.
Also this variable is replicated like this:

Header:
	UPROPERTY(BlueprintReadOnly, Category = Movement, Replicated)
		bool _bIsSprinting;
Cpp:
void UZA_CharacterMovement::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps) const
{
	DOREPLIFETIME_CONDITION(UZA_CharacterMovement, _bIsSprinting, COND_SkipOwner);
}

You can see that this method is fired from a base class CharacterMovement, and that the playercontroller uses a class called UZA_PlayerMovement this is because Playermovement as some extra behaviour that is needed to handle the camera. and when I apply UZA_CharacterMovement to an enemy he only needs the movementbehaviour and not the camera handling because an enemy does not have a camera.

Maybe I forgot something but I checked everything exept the right thing ofcourse -_-’

Kind Regards

Dyronix

what your question actually ? If for to recognize character or enemy, you always can check the valid of PlayerController of that character to know if you have the direct control or not, unreal have 1 function u can access from Pawn is IsLocallyControlled(). Then u can choose how to handle stuff with camera.

My question is why does is my character movement not replicated.
I check if my controller was valid and it is. If I play on the server it works, but when I swap to the client nothing happend according to the client the server did not move

ok, did you set the sprint value in this ServerSetSprint_Implementation(bool bNewSprint) ?

Yes

I call the same method inside ServerSetSprint like this:

void UZA_CharacterMovement::ServerSetSprint_Implementation(bool bNewSprint)
{
	GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Red, "Sprint" + this->GetName());
	SetSprint(bNewSprint);
}

ok, do you set bReplicates = true in constructor of UZA_CharacterMovement

Yes I did.

I fixed my bug.
forget to call the super in my character class
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
Thanks Anyway