Handling collisions with c++

Hi guys i cant seem to find a way to detect colliding objects with a sphere component in my actor.
Is there some function like unity “onCollisionEnter(colliders[])”? i cant seem to find it in the API
I just want to send a “message” to all colliding objects touching this sphere component.

Thanks in advance! this is a great community.

You can do it this way :

//mSphereComponent is your sphere component
mSphereComponent->OnComponentHit.AddDynamic(this, &AMyClass::OnHit);

//The OnHit signature :

void AMyClass::OnHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)

From the OnHit function, you get the colliding Actor and it’s colliding component, so you can use that to send your “message”.

Hope this helps!

Mick

Oh, got it, its a UPrimitiveComponent variable, im just new to delegates, never expected to find this here.
Thanks!

For anyone else looking how to do this, I think it’s changed in newer engine versions. It’s now:

//mSphereComponent is your sphere component
 mSphereComponent->OnComponentHit.AddDynamic(this, &AMyClass::OnHit);
 
 //The OnHit signature :
 
 void AMyClass::OnHit(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)