C++ code for displaying the clicked actor's name in the scene

Experts,

  I have written custom C++ code for my gamemodebase, player controller and actor. Right now, when I click my actor I am able to get the actor name. I was able to get this as part of the OnClick event. However, I want to display the selected actor's name right on top of it in the scene. Appreciate any help on this with C++.  As shown below in the image, the output log shows the selected actor's name, but want to display the name on top of the blueprint actor . Appreciate any help on this.

You may do it through adding “UWidgetComponent” to the Actor. It is NOT widget like in hud. It is Widget in 3d space. There is Text variable where you can type whatever you want. Don’t forget to select the “display in the world” something like this setting, otherwise it won’t be shown. And don’t forget manually place the widget above the actor. If you need C++, I suppose inside OnClick function you have something this:
widgetcomp->text = actorvariable.GetName(). And of course you need to clean text if you dont want to show name forever.
If it’s error on build than in build.cs file add “UMG” in modules rigth after Core Engine and InputCore, you’ll see.

I’m not telling you what specific code you need to type, because I don’t see yours, there are a lot of ways to do it.