Download

Physics Mesh Location not replicated to clients

Hello,
If i enable the physics of the mesh it’s not correct on the clients anymore, only on the server.
Working fine if it’s disabled though.
Any ideas why or how i can keep it in synch?

.cpp:



ABaseItem::ABaseItem()
{
	bReplicates = true;
	PrimaryActorTick.bCanEverTick = true;
	Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Mesh"));
	RootComponent = Mesh;
}

//------------------------------------------------------------------------

void ABaseItem::execSetInWorld(FVector Location)
{
	this->isOwned = false;
	this->SetActorHiddenInGame(false);
	this->SetActorLocation(Location, false);
	Mesh->SetSimulatePhysics(true);
	Mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
}

bool ABaseItem::SetInWorld_Validate(FVector Location)
{
	return true;
}

void ABaseItem::SetInWorld_Implementation(FVector Location)
{
	this->execSetInWorld(Location);

	if (Role < ROLE_Authority)
	{
		this->Server_SetInWorld(Location);
	}
}

bool ABaseItem::Server_SetInWorld_Validate(FVector Location)
{
	return true;
}

void ABaseItem::Server_SetInWorld_Implementation(FVector Location)
{
	this->execSetInWorld(Location);
}
//------------------------------------------------------------------------

.h:


	void execSetInWorld(FVector Location);
	UFUNCTION(Client, Reliable, WithValidation)
		void SetInWorld(FVector Location);
	virtual bool SetInWorld_Validate(FVector Location);
	virtual void SetInWorld_Implementation(FVector Location);

	UFUNCTION(Server, Reliable, WithValidation)
		void Server_SetInWorld(FVector Location);
	virtual bool Server_SetInWorld_Validate(FVector Location);
	virtual void Server_SetInWorld_Implementation(FVector Location);

e/ Okay, found a solution to replicate the position each tick, but this doesn’t seem… right to me.