Get Overlapping Actors C++ vs Blueprints

The technique Sam uses to check if he can grab is similar to how the VR template determines if there is an eligible actor to grab–at least in the sense that they both use GetOverlappingActors. In blueprints, the GetOverlappingActors node allows us to plug the sphere collision of the hand controller actor into the target input pin, whereas the C++ function counterpart has no such input or reference to any particular component. Does the C++ function use all the components (at least those with the correct overlap settings) in the actor to determine whether or not another actor is overlapping the actor or is there a way to specify which actor component to use when determining which actors are overlapping?

It really depends on where you’re trying to detect the collision. The most logical place would be the hand controller. In the UHandController, the following event is added:

ActorBeginOverlap( AActor* OverlappedActor, AActor* OtherActor )

This gives you the OtherActor which I assume is what you’re looking for.

Apologies, I wasn’t clear enough with my question. I’m just trying to figure out the difference between the C++ version and the blueprint version of the Get Overlapping Actors function.

In blueprints, the node looks like this:
GetOverlappingActorsNode

There is a “Target” input pin where we can put the specific collision component that we want to use to find overlapping actors. This is how it is done in the VR Template.

However, in C++, there is no such way to specify which collision component we are using to find overlapping actors. It only takes a TArray out parameter and an optional TSubclassOf filter, like so:

void GetOverlappingActors
(
    TArray<AActor*> &OverlappingActors,
    TSubclassOf<AActor> ClassFilter
) const

Here is my question. How does the C++ version determine which collision component on the actor (in this case, the Hand Controller actor) to use when trying to find overlapping actors since we cannot specify like we can with the blueprint version? Suppose there were two collision components for some reason. Does the C++ version just use both collision components when determining which other actors are overlapping since we cannot specify which collision component we want to use like with the blueprint node version?

Ok, I follow you now. In the case of the blueprint, the target is the Grab Sphere. This I am assuming would be your USphereComponent. This would be the item you call GetOverlappingActors on. So, Sphere->GetOverlappingActors(outArray, classFilter)

I can’t find the docs on this however.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms