OnHit is not working c++

What does your .h look like ?

I have been creating a level in where a door opens when the player character walks into it. I have set up a OnHit for the door, but when the character walks into it; it doesn’t respond.

Here is my OnHit code, my character is called theWolfCharacter

void APushDoor::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{	
	if (OtherActor->GetName().Contains(TEXT("character"), ESearchCase::IgnoreCase, ESearchDir::FromStart))
	{
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("shot hit asteroid"));
		}
	}
	
	doorHit = true;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("door hit"));
		}
}

Sorry about the delay, I’ll give my whole .cpp and .h files using paste bin since there are too many characters for a response :S

.cpp → pushDoor CPP - Pastebin.com

.h → doorOpen.h - Pastebin.com

Thank you in advance :slight_smile:

Your OnHit function will not be called because it is not bound to anything, you should rather override the NotifyHit function and do your logic in it.
“Simulation Generates Hit Events” should not be neccessary as the character movement will trigger it anyways.

“Simulation Generates Hit Events” set to true under the collision tab in blueprint.
Also, it might be a good idea to have a delegate going on the constructor.