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