GetOverlappingActors

I have actor Sphere that spawns a sphere and I have an Actor SpawnVolume that is a BoxComponent that on BeginPlay() spawns the Sphere randomly within the BoxComponent. I know how to check for overlapping actors within blueprint, but can’t seem to figure it out in c++. I want every tick to check the randomly created sphere for any characters that are either inside or outside this sphere.

Thanks for the response!

I was able to figure this part out. And I think I am checking to see if it is the client’s character who overlapped with the sphere. But ultimately what I want is a class that only ticks on the server, checks for overlapping characters only, and if it finds one it displays to only that clients screen it was overlapping.
This is what I have so far:
I can run

if (HasAuthority())
	{
    	AIrisCharacter* MyCharacter = Cast<AIrisCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
    	
    	TArray<AActor*> Sphere;
    	BaseCollisionComponent->GetOverlappingActors(Sphere);
    
    	for (int32 b = 0; b < Sphere.Num(); b++)
    	{
    		AActor* const testCharacter = Sphere[b];
    		if (MyCharacter && testCharacter->IsOverlappingActor(MyCharacter)) {
    		}
    	}
}

I guess the issue I have is I need to get a list of all available characters, and loop through that as well against the array of collisions? I’m not sure if there is a better way to check that isn’t that taxing?

Hey thanks for replying so fast again!

The problem I have is I want to spawn a collision sphere component into my level, and then I want to see if any characters are outside the component. If they are I want to print to that characters screen. Would doing this on the characters actor class be the best option? I think I could use OnActorBeginOverlap for every Actor individually and then set a bool to false by default and if it overlaps then set it to true and if it gets OnActorEndOverlap set it to false? My concern is, would this be the best performance wise? As this is running on the clients machine now, and if this is something I could do on the server and reduce client load I would prefer that.

If I check with every Character’s Actor, I’m not sure how to reference the sphere that is created on runtime int the actors playercontroller… I know it’s probably some silly like referencing the class or getting everything with that class and checking. But I’m really unsure.

printing text to a characters screen sounds like an event, rather than an ongoing process, so avoiding tick by using begin and end overlap events, would be better for performance than checking for arrays every tick.

I switched back to blueprints as I decided I am going to just focus on gameplay mechanics first in blueprints and get everything ironed out then switch it over to c++. I took your suggestion and created a bool that is set if the character is in the sphere. It works well, as I just check from within the character class if it overlaps the sphere class I created. Thanks for the help.