Simulation Generate Hit Events boolean in C++?

Hi i am trying to code my demo in full C++ but i am stuck.

I am looking for the “Simulation Generate Hit Events” boolean on my mesh.

19787-capture.png

I already find “bGenerateOverlapEvents” for the overlapping event but where is the equivalent for the hit event ?

I did something like this :

	mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
	const ConstructorHelpers::FObjectFinder<UStaticMesh> MeshObj(TEXT("/Game/Meshes/SM_WallKey"));
	mesh->SetStaticMesh(MeshObj.Object);
	mesh->BodyInstance.SetCollisionProfileName("PhysicsBody");
	mesh->OnComponentHit.AddDynamic(this, &AKeyWall::OnHit);
	RootComponent = mesh;

In fact at the beginning I thought the “OnComponentHit” was enough but when I tried it wasn’t (There is collide but my event didn’t fire)
After that i see if y a create a BP child of my class and check the “Simulation Generate Hit Events” my Hit event work perfectly.

If someone can explain me how to enable event on Hit.

Thanks in advance and sorry for my english :wink:

2 Likes

Found my Answer : the boolean is called “SetNotifyRigidBodyCollision”

I think it’s the old name on the editor interface :slight_smile:

3 Likes

Thanks Sir for posting your solution, I was really hoping I’d find an answer to this.

+1 Thanks! I really wish Blueprint and C++ variable names were a little more consistent.

Same problem here, thanks!

Seems the function is actually called “SetNotifyRigidBodyCollision” also in blueprints. However, that the property is called “Simulation Generates Hit Events” is very confusing. And thanks for the answer, I needed this while prototyping in blueprints!

thanks man , i save mi life

You should just set it in C++ code like this.

YourMeshComponent->BodyInstance.bNotifyRigidBodyCollision = true;

You’re welcome :smiley: