AActor::NotifyActorOnClicked
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Called when the player clicks on this actor while click-events are enabled. Override in C++ to handle per-button click logic; ButtonPressed identifies which button triggered the event.
Caveats & Gotchas
- • Requires bEnableClickEvents on the PlayerController; it defaults to false and is commonly overlooked, leading to the event silently not firing.
- • The actor also needs a collision component with the correct query trace channel set to Block for the click trace to hit it; a mesh with no collision will never receive this call.
Signature
ENGINE_API virtual void NotifyActorOnClicked(FKey ButtonPressed = EKeys::LeftMouseButton); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ButtonPressed | FKey | The mouse button that was pressed. | EKeys::LeftMouseButton |
Return Type
void Example
Respond to left-click in C++ C++
void AMyActor::NotifyActorOnClicked(FKey ButtonPressed)
{
Super::NotifyActorOnClicked(ButtonPressed);
if (ButtonPressed == EKeys::LeftMouseButton)
{
UE_LOG(LogTemp, Log, TEXT("Left-clicked!"));
ActivateActor();
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?