Best way to do OnComponentBeginOverlap and OnComponentEndOverlap?

Currently I’m using:

void AMainCharacterTesting::OnComponentBeginOverlap(AActor* OtherActor /*Rest removed cause hard to read*/)
{
	if (ATargetDummy* TargetDummyCheck = Cast<ATargetDummy>(OtherActor))
	{
		if (TargetDummyCheck->bIsTargetable)
		{
			LockOnCandidates.AddUnique(OtherActor);
		}
	}
}

void AMainCharacterTesting::OnComponentEndOverlap(AActor* OtherActor /*Rest removed cause hard to read*/)
{
	if (ATargetDummy* TargetDummyCheck = Cast<ATargetDummy>(OtherActor))
	{
		LockOnCandidates.Remove(OtherActor);
	}
}

This is for a box collision component that is attached to the spring arm component and follows its location and rotation. Currently it works but I have a few problems with it cause when I want to detect if a pawn is overlapping with the box collision and I move out of range of the collision and move my camera so that the collision is in range the overlap events don’t run unless my character has moved.
Here’s a video showing this:

Begin and End overlap do not register the event on begin play, so you do not get the initial check of if an object is within the bounds of the component.

You would have to write an extra step in begin play (you can call a function) that does a custom trace and triggers the overlap event if needed.

Oh I know this is after I just cut the start since that’s not the problem.

Instead of using a component overlap why not just use a box trace from the camera location + rotation. It will register both when standing still and moving.

Lol was just considering that. Ty for the replies tho.:slight_smile: