Hi, I am having an issue where the collision does not follow the player while attached to the Mesh.
I’m using the following code:
visibilitySphere = CreateDefaultSubobject(TEXT(“VisibilitySphere”));
Which does create the collision, but while playing the game does NOT follow the Mesh.
Help would be appreciated.
If you look at the default character implementation you’ll notice it’s the collision component that’s set as the root component with the mesh being attached to it rather than the other way around, which makes sense since collision is what determines an object’s location in the world in relation to other objects from a physics perspective, and a mesh is just a visual indicator. Here’s how it’s done:
CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Collision"));
RootComponent = CapsuleComponent;
Mesh = CreateOptionalDefaultSubobject<USkeletalMeshComponent>(TEXT("Mesh"));
Hope that helps.