GetComponent not available as an option

Hey guys, in the Using Physics Handle video (for Building Escape) they have the line as follows:

auto ComponentToGrab = HitResult.GetComponent()

However, I don’t have an option for GetComponent() I have other options such as GetComponents() plural or GetComponentByClass, GetComponentsByClass, GetComponentsBoundingBox, etc.,

Also, I’m unable to use the .(dot) operator, instead the IDE is auto changing the .(dot) operator to the ->(pointer) operator.

And finally, just in case you are wondering, I am explicitly including the “Runtime/Engine/Classes/PhysicsEngine/PhysicsHandleComponent.h” header at the top of the .cpp file so I am “Including What I Use”.

Any pointers (no pun intended) for me? Thanks!

The only thing I can think of is that auto is getting what you’re not wanting. GetComponents() is part of AActor https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/GetComponents/2/index.html but GetComponent() is a part of FHitResult http://api.unrealengine.com/INT/API/Runtime/Engine/Engine/FHitResult/GetComponent/index.html

It may just be that you have the wrong object for HitResult maybe and so you wouldn’t get the GetComponent() function if it isn’t the object that supplies it. One of the downsides to auto is if that happens.

If you swap auto with FHitResult you can see if its correct or not (when getting HitResult eg FHitResult HitResult = … )

If it is correct then I can only think its an IDE issue.

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

Privacy & Terms