How to change collision profile?

Hello dear community,

I have some actor. I can change it’s collision profile in editor and everything works fine. For example, if I set it’s collision preset to “NoCollision” - it just fall through the floor. Now I want to change it in code, i.e. at some point I want my actor to ignore, say, a pawn. How? I tried SetCollisionProfileName(), SetCollisionResponseToChannel() and even SetCollisionEnabled(false) - nothing works.

Hi :smiley:

Try this to change the collision for all channels:



YourActor->SetActorEnableCollision(true);
YourActor->StaticMeshComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
YourActor->StaticMeshComponent->BodyInstance.SetResponseToAllChannels(ECollisionResponse::ECR_Block);


For individual channels try:



YourActor->SetActorEnableCollision(true);
YourActor->StaticMeshComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
YourActor->StaticMeshComponent->BodyInstance.SetResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);


hopefully this helps :smiley:

Nope, that doesn’t work. Nor in code nor in blueprints.

Upd.: well, actually this works for actor placed on scene by hand in editor. It not works for actor spawned on server with code. Will dig deeper.