Why doesn't ReceiveHitBoxClick get called?

Hi!

I have added a hitbox (in my AHUD class) but when I click in it nothings happen even though I overloaded “ReceiveHitBoxClick”. I’m using

bShowDebugInfo = true; bShowHitBoxDebugInfo = true;

to make sure I click in the hitbox and

bShowMouseCursor = true; bEnableClickEvents = true;

in hope to enable mouse input.

I have the same problem. I saw some guy do it in Blueprint but in C++ there seems to be something missing… Flag to set or something. If anyone knows about it please let us know.
Also this is being discussed here too so keep track of it in case somebody replies there.

That’s another of my many questions. Thanks anyway =)

Edit: As Marc Audy says below the issue is in the player controller bEnableClickEvents needs to be set to true on the player controller. Overriding PostRender is not necessary or desirable.

I got this working in 4.1. Basically the issue (or maybe its a non issue) is that in the base AHUD class they never call the method AHUD::UpdateAndDispatchHitBoxClickEvents. Maybe they never do call it because they want the user of the class to be able to choose what button should trigger click events etc…not sure.

So here is what i did to fix it. In your custom class that inherits from AHUD override PostRender like so

void AGameHUD::PostRender()
{
	Super::PostRender(); //Do this first so everything gets drawn and all hitboxe collections are populated.  This base class method also handles dispatching the mouseovers events.

	if(this->GetOwningPlayerController()->WasInputKeyJustPressed(EKeys::LeftMouseButton))
	{
		this->UpdateAndDispatchHitBoxClickEvents(IE_Pressed);
	}

	if (this->GetOwningPlayerController()->WasInputKeyJustReleased(EKeys::LeftMouseButton))
	{
		this->UpdateAndDispatchHitBoxClickEvents(IE_Released);
	}


}

then just override the corresponding events ReceiveHitBoxClick / ReceiveHitBoxRelease.

by doing this I now have mouse overs and clicks working on my hitboxes.

I will check this out next time I try to make a GUI. Thanks!

UpdateAndDispatchHitBoxClickEvents is called from APlayerController::InputKey when left mouse button is pressed (which button used is under consideration for making configurable though). bEnableClickEvents does need to be true on the player controller class.

It seems less desirable to be manually doing this through PostRender.

Ah thanks Marc. I thought I had that set in the player controller but turns out I didnt. figured i was missing something easy.