Question on Grabbing the Gargoyle using Grab Component function

The is my code for Implementing the GrabComponentAtLocationwithRotation

image

GrabComponentAtLocationWithRotation Arguments:

The code works I’m just trying to understand how the PhyusicHandle identifies the Gargoyle Statue as the object it is to control.

I understand that HitResult is an out parameter provided by the SweepSingleByChannel which gives the means to get information on the SM_Gargoyle_Statue.

Looking at the SM_Gargoyle_Statue I can see it does have a StaticMeshComponent , is that the actual geometry of the Statue which SweepSingleByChannel uses to detected collisions?

If I look up in StaticMeshComponent in the Unreal Doc it takes me to the UStaticMeshComponent description, which has an Inheritance hierarchy which includes UPrimitiveComponent

So, in summary when I call HitResult.GetComponent() is it returning a pointer from the StaticMeshComponent child of the SM_Gargoyle_Statue then is it able to perform a implicit cast to UPrimitiveComponent due to the Inheritance hierarchy or does this work in a different way?

Yes.

Yes but it’s returning it as UPrimitiveComponent*. In order for FHitResult to be able to store different types of components that could be hit it needs to do so as the highest base class possible and UPrimitiveComponent's are:

PrimitiveComponents are SceneComponents that contain or generate some sort of geometry, generally to be rendered or used as collision data.

So going up one more to SceneComponent doesn’t make sense as it would be impossible to ever hit a scene component. If it was storing UStaticMeshComponent then it wouldn’t be able to store UShapeConponent’s or `ULandscapeComponent’s.


Here is a code example to illustrate: Compiler Explorer

1 Like

Thanks Dan,

Thats very helpful.

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

Privacy & Terms