I’m developing a game in a Listen Server environment, and I’m encountering an issue related to setting mesh transform values when using a class derived from ACharacter
.
What works:
When I set the skeletal mesh and its transform in the constructor like this:
cpp
복사편집
GetMesh()->SetSkeletalMesh(SomeMesh);
GetMesh()->SetRelativeLocation(FVector(0.f, 0.f, -90.f));
GetMesh()->SetRelativeRotation(FRotator(0.f, -90.f, 0.f));
everything works as expected — all clients, including the host and connected players, see the correct mesh position and rotation.
What fails:
However, if I try to set the mesh’s position and rotation in BeginPlay()
, after loading mesh and animation data from a data table, the values appear to be overwritten or reset during runtime.
More specifically, in a Listen Server setup:
- The host (server + client 0) sees everything correctly.
- Other clients see the mesh at the default location
(0, 0, 0)
with no rotation applied.
Even using a replicated function like this doesn’t fix the issue:
cpp
복사편집
void ASurvivor::Server_MeshPos_Implementation()
{
Multicast_MeshPos();
}
void ASurvivor::Multicast_MeshPos_Implementation()
{
GetMesh()->SetRelativeLocation(FVector(0.f, 0.f, -90.f));
GetMesh()->SetRelativeRotation(FRotator(0.f, -90.f, 0.f));
}
But the transform still seems to get overwritten for remote clients.
Question:
Why does this happen, and how can I correctly apply mesh transform values at runtime (such as in BeginPlay
) so that all clients, including remote ones, consistently see the correct mesh transform?
Any guidance would be appreciated!