Download

Clicking on actors 2d componant not firing events

Hello Friends.
i have a problem i think it,s very easy to solve but i have tried to solve but i failed.

Screenshot_1.png
**The problem is **
i have 2500 actor in world (2d sprits)
i am trying to make actor listen to clicking events with 4 ways but all have failed

1st way
**


**
OnClicked.AddUniqueDynamic(this, &AWorldUnitSprite::OnSelected);
**


**void AWorldUnitSprite::NotifyActorOnClicked(FKey ButtonPressed)
{
Super::NotifyActorOnClicked(ButtonPressed);
UE_LOG(LogTemp, Warning, TEXT("Am here 15"));

}
**

**

3rd way



void AElkaisarController::SetupInputComponent()
{
Super::SetupInputComponent();
check(InputComponent);
InputComponent->BindAction("MouseClick", IE_Pressed, this, &AElkaisarController::OnMouseClick);
}

void AElkaisarController::OnMouseClick()
{
FHitResult HitResult;
GetHitResultUnderCursor(ECollisionChannel::ECC_Pawn, false, HitResult);

if (HitResult.GetComponent())
{
GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Red, FString::Printf(TEXT("Mouse Click+++ Component: %s"), *HitResult.GetComponent()->GetName()));
}

if (HitResult.GetActor())
{
GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Red, FString::Printf(TEXT("Mouse Click+++ Actor: %s"), *HitResult.GetActor()->GetName()));
}

}


All three ways failed to trigger click events
My controller class is enabling click events



AElkaisarController::AElkaisarController()
{
bEnableClickEvents = true;
bEnableTouchEvents = true;
bShowMouseCursor = true;
bEnableMouseOverEvents = true;
bEnableTouchOverEvents = true;
EnableInput(this);

}


and My Actor constructor is


AWorldUnitSprite::AWorldUnitSprite(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

//Create a default UPaperSpriteComponent and register it to this Actor
Sprite = ObjectInitializer.CreateDefaultSubobject<UPaperSpriteComponent>(this, TEXT("SpriteComp"));
RootComponent = Sprite;
ObjectInitializer.CreateDefaultSubobject<APawn>(this, TEXT("MovementComp"));
bBlockInput = false;
EnableInput(UGameplayStatics::GetPlayerController(GetWorld(), 0));

}



i have searched for the solution but found no thing helps me
thanks for your help