Download

Collision Presets and CCD in C++

Is there a way to set collision presets in C++? Also, how to set CCD to true in C++?

Somewhere in the actor that owns the mesh you want to change collision response to, change it like so:



Mesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Block);


No, this is not what I asked… I need to changing collision preset for example from “BlockAll” to “OverlapAll”. Off course I can just change every object responses to overlap, but it is too massive. And what if I will make some custom collision response.
I’ll have to change it in every code of the fact that I need.

The channels live on the UPrimitiveComponent and there’s a simple method call to change all of responses:



if (UPrimitiveComponent* PrimitiveComponent = Actor->FindComponentByClass<UPrimitiveComponent>())
{
   PrimitiveComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
}



There’s a bunch of other methods to set specific channel responses, get the current response, etc.

This thread is the first result I got in Google, so I’ll link the answer I found in another thread:

How Do You Set Custom Collision Presets from Code?

2 Likes