Check the class of a weak pointer from a hit result

Been searching for an answer, and I’m not sure if I’m phrasing my question correctly…

Is there a way to check the class of a weak pointer?

In my player pawn, I’m using GetHitResultUnderCursor to get a HitResult on each mouse click. What I’d like to do is check the class of the object to then display a contextual menu based on what object was hit.

Displaying the menu isn’t the issue; I seem to have figured that out. But I’m confused on what to enter in my If statement to check if the hit result is a specified class…

Hi, I guess you can just do this

	AActor* Pointer = WeakPointer.Get();
	UClass* ActorClass = Pointer->GetClass();

So get a pointer from the weak pointer and then check the class.

And to check if it the same as some other class just

ActorClass == WantedClass

1 Like

THANK YOU! This was super helpful – working as intended, now. Appreciate the help :slight_smile: