Why does a c++ generated static mesh not block my collision channel?

Hi,

I am using a trace to detect an actor on the floor, the trace and collision channel both work fine on an ordinary static mesh added to the actor in engine. However when I replace this mesh with a static mesh component created in c++, the trace fails to be blocked even though the collision settings are identical.

I’ve found a few issues with C++ generated objects and collision. Particularly I’ve found that attaching and detaching components will sometimes blow away all of your custom collision and physics settings.

My solution was to set all of my collision channels again after attaching or detaching components. Even if you aren’t attaching/detaching components, are you sure you set all the channels correctly in code? It looks something like this where CollisionComp is a primitive component:

// Set up the collision channels
CollisionComp->BodyInstance.SetCollisionProfileName("Custom");
CollisionComp->SetCollisionObjectType(COLLISION_TETHERBALL);
CollisionComp->SetNotifyRigidBodyCollision(true);
CollisionComp->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
CollisionComp->SetCollisionResponseToChannel(COLLISION_PLAYERMOVEMENT, ECollisionResponse::ECR_Ignore);
CollisionComp->SetCollisionResponseToChannel(COLLISION_TETHERBALL, ECollisionResponse::ECR_Ignore);
CollisionComp->SetCollisionResponseToChannel(COLLISION_PLAYERPAWN, ECollisionResponse::ECR_Ignore);
CollisionComp->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics, true);

As a reference, my custom collision types are:

#define	COLLISION_PLAYERMOVEMENT	ECollisionChannel::ECC_GameTraceChannel1
#define	COLLISION_TETHERBALL		ECollisionChannel::ECC_GameTraceChannel2
#define	COLLISION_PLAYERPAWN		ECollisionChannel::ECC_GameTraceChannel3

I have a similar problem. I also found I need to manually recreate physics state when I attach component to the other. Otherwise no collisions are processed for that attached component.