How do you receive input in AHUD [C++]


How should you setup your player controller class and a custom HUD class in order to being able to receive mouse inputs?

You can use FViewport and FViewportClient to recive mouse input on game screen

You can grab viewport object of your viewport from GEngine-> GameViewport

You could also try to use Slate for gui (if you want to make more RTSish HUD) it should have ready click events, but currently Slate is not very well documented.

Is there a way to get the events in AHUD to trigger like e.g. ReceiveHitBoxClick or are you supposed to trigger those yourself?

Oh i didnt know about those :slight_smile: Look on source code you just need tocCreate hitbox with AddHitBox:

AddHitBox(Position, Size, Name, bConsumesInput, Priority = 0)

And then override ReceiveHitBoxClick(FName Name) in your HUD class which will be called when hitbox is clicked and it will give name of clicked hitbox in Name.

I though so too but it doesn’t work for me, hmm… Anyway if I don’t find a solution soon I will stick to your first answer and implement a similar “GUI hitbox” system myself. I’m probably missing some flag or similar during initiation of my objects.

#800+ Lines of Code, Sample HUD Class Writing to Canvas

I have posted an 800+ line complete sample class, and a VIDEO demoing it here:

800+ Line Sample HUD Class

Thank you!

I was wondering the exact same thing. After watching a video demoing how to use hit box in a HUD from a blueprint I tried doing it in C++ with no luck. Could anyone point us to what we are missing ?