Download

Need Conceptual Explanation To Show Actor Name Above Actor When Looked At

Basically I want my Item actor to show it’s name in a HUD above itself when my character is within a certain radius and is “looking at it” (center reticle is over it). Can you please explain in high-level terms how this would be done? I’m unsure if some of this should go in the Character class or all in the Actor class, etc.

I’m getting really good with the code, just not the concepts… :frowning:

Thanks!

Easiest way would be to add a Volume to your main character, check the overlapping actors within it, on each tick, from there check the distance of each overlapped actor to your main character, and if the distance <= maxDistance, spawn the HUD

Thanks so much! Would I spawn the HUD from the character class or from the HUD class? I’m guessing character, right? Also, if I wanted to put a label for the item on screen upon this “hover”, would that go in the Actor class or the Character class? Thanks, again.

No idea, never worked with UE4’s HUD, but should be fairly easy if you explore or look at some tutorials

This will be possible using UMG widgets very soon (mentioned on the twitch stream for ver 4.6), they are going to enable widgets to be placed anywhere & attached to anything in the world. So if you can wait for that it will be so much simpler to do in UMG instead of a HUD.

One way to do this is to just get the target actor’s position, translate it to screen space, and then simply draw text in the HUD at that position. You could make the text a fixed size or scale it depending on distance. This gives a very HUD/floating look though.