No replication through AddLocalOffset?

Hi,

My character has a sphere (static mesh) as a child component (pic. 1).

The character is correctly replicated and the sphere follows its parent correctly as long as i move the character.

But the sphere is supposed to be remotely controlled, and when i do this, the sphere is not replicated any longer (pic. 2):

  • right (local point of view): the sphere is moving toward the table as it is supposed to. All ok.
  • left (non local point of view = point of view of another character): the sphere is still stuck to the character.

So the sphere position is replicated when i move the whole character, but it is not when i move the sphere alone.

Here is the sphere declaration in the character header (adding “Replicated” leads to a compile error):

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Hand)
		TSubobjectPtr<UStaticMeshComponent> Hand;

Here is the creation of the sphere in the cpp file:

	Hand = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Hand"));
	Hand->AttachParent = CapsuleComponent;

And here how it’s moved around (the LookUp function is called on mouse up/down movement):

void AYagCharacter::LookUp(float Value)
{
	if (!IsHandPossessed)
	{
		AddControllerPitchInput(Value);
	}
	else
	{
		Hand->AddLocalOffset(FVector(-HandSpeed*Value, 0, 0), false);
	}

}

Can anyone help me understand what i am doing wrong ?

Thank you
Cedric

Just in case.

Following this post:

https://answers.unrealengine.com/questions/26116/able-to-replicate-movement-when-using-addmovement.html

i tried to modify the BaseGame.ini file, adding this:

MAXPOSITIONERRORSQUARED=625
 ClientAuthorativePosition=true

to the [/Script/Engine.GameNetworkManager] block.
It didn’t change anything.

Cedric

Just in case someone is interested, a part of the solution is to use the SetIsReplicated function for the component.

Hand->SetIsReplicated(true);

Then the replication is ok from the server to the client, but not from the client to the server.

But i think the client → server communication is another problem.

cedric

Ok, everything works fine now.

The component replication was handled by the SetIsReplicated function and i used RPCs to send messages from the client to the server.

This ticket can be marked as solved.

Cedric