Collision Presets and CCD in C++

Terzalo’s answer is correct. But I do find it kinda dangerous to hardcode strings in such manner, in case you (or your game designer) changes their name in future. Unreal does pop up a warning when there’s no Collision Profile with the given name, but it is easy to miss (check BodyInstance.cpp for more details).

With that in mind, I wanted to share my solution, in case someone else wants to setup this in a C++ - BP integrated environment:

  1. After creating your custom Collision Profile in Projects settings, create an variable in your header file as such:
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta=(AllowPrivateAccess="true"))
	FCollisionProfileName CollisionProfile;
  1. Set the variable in your Blueprint’s Class Defaults. The only options available will be the existing Collision Profiles, so there is no way to pick one that does not exist.

  1. Use the SetCollisionProfileName function (called from a UPrimitiveComponent or a child class, such as UBoxComponent or UShpereComponent):
PrimiteComponent->SetCollisionProfileName(CollisionProfile.Name, true);
8 Likes