Simulate physics for mesh with everything except players

In my multiplayer game, a gun spawns at a random location in the world, which the player can pick up.

I want the gun’s mesh to simulate physics with everything in the world, but not have any physical interaction with the players in the game. Right now, when a player walks over the gun, they can move the gun. I don’t want that.

Is that a way to simulate physics for a mesh but have physics toggled off for any players in the world?

I’m aware of the **SetCollisionEnabled **functionality and I tried all the options for it suggested by Visual Assist but none of them was what I was looking for.

My simplified code for reference:


AGun::AGun() {
    UStaticMeshComponent* Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    Mesh->SetupAttachment(RootComponent);
    Mesh->SetSimulatePhysics(true);
}