Does MESH replicate to all clients?(Character Class)

I have a function that gets called on all clients and it sets the skeletal mesh component.

Problem is when the


GetMesh()

gets called on clients the game crashes. Any reason why its happening?

I’m betting that the mesh is never actually set on Clients to begin with, and you’re dereferencing a NULL pointer when you call that function.

GetMesh() is an inline that just returns the Skeletal Mesh. If there isn’t one set, then it returns null. I guess you don’t do if (GetMesh()) before you try to do stuff with it?


	Mesh = CreateOptionalDefaultSubobject<USkeletalMeshComponent>(ACharacter::MeshComponentName);
	if (Mesh)
	{
		Mesh->AlwaysLoadOnClient = true;
		Mesh->AlwaysLoadOnServer = true;
		Mesh->bOwnerNoSee = false;
		Mesh->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::AlwaysTickPose;
		Mesh->bCastDynamicShadow = true;
		Mesh->bAffectDynamicIndirectLighting = true;
		Mesh->PrimaryComponentTick.TickGroup = TG_PrePhysics;
		Mesh->bChartDistanceFactor = true;
		Mesh->AttachParent = CapsuleComponent;
		static FName CollisionProfileName(TEXT("CharacterMesh"));
		Mesh->SetCollisionProfileName(CollisionProfileName);
		Mesh->bGenerateOverlapEvents = false;
		Mesh->bCanEverAffectNavigation = false;
	}

Gets called during the actor constructor. So it should be called on clients. Not completly sure though…

In a nutshell, I want to call GetMesh()->SetSkeletalMesh() on clients or set their mesh by some other means
.

--------------------------------Solved---------------------

OwningPawn was invalid on clients but it was still calling the function to the pawn without any errors.