Depends a bit on what you are actually trying to do.
If you just want something to happen when an actor collides with the player character all you need to do is set up the collision channels. Then implement the appropriate event (Either on the player or the actor depending on what makes the most sense). The collision checks will be handled by the engine and then call the collision events when the objects collide.
Check these links for more on how the collisions work:
To expand slightly, the collision checks typically happen on a frame by frame basis as your characters move, or when you attempt to manually move using SetActorLocation and set the bool to true. I’m not sure how to manually do a collision check though. Maybe you could save the current location, movement vector, and rotation of the actor, do a SetActorLocation at the new place to check for collisions then set it back? There is probably an easier way as this sounds needlessly complicated.
It’s for pickups… I would like to use some kind of iteration over the nearest actors… if there is a collision with the pickup actor, then add 1 to the score of my player… I’d prefer to do this in C++ as I have some logic to apply to the point system from an existing project.
APickupBase::APickupBase(const class FPostConstructInitializeProperties& PCIP)
PrimaryActorTick.bCanEverTick = true;
// Set up a component to collide with
CollisionSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("CollisionSphereComponent"));
CollisionSphere->bGenerateOverlapEvents = true;
// Set up a delegate function and assign it to run the CollisionOccured function (this can be named anything)
// Say when you want the delegate function to be run (in this case, On overlap of components)
// Make sure to set your root component to the collision thingy
RootComponent = CollisionSphere;
// Then create the function that will be called by your delegate
void APickupBase::CollisionOccured(AActor* actor)
// In my case I wanted to delete the actor that the collision occurred on, so I just call this here!