[C++] Collision detection?

I have an actor with a static mesh component, how would I detect a collision with the static mesh component and other actors? What virtual functions must I override?

Hi Skydive,

You should add delegate

 OnActorHit.AddDynamic(this, &AQAPawn::OnMyActorHit);

 void MyActor::OnMyActorHit(AActor SelfActor, AActor OtherActor, FVector NormalImpulse, const FHitResult& Hit)
       // to do smth

Also in Actor exist function you can find useful:

Best regards,

For some reason, this does not work. My actor extend AActor and has its root component as a StaticMeshComponent. ReceiveHit doesn’t work. The delegate here does not work either. They’re simply not called

Have you looked at all the documentation available on collision by epic? I am sure if you look around a bit you will understand/find more about this topic.

Hello Skydive,

Make sure you set up everything correctly.
Try to use this


In addition, look at collision options Collision in Unreal Engine | Unreal Engine 5.1 Documentation