GetActorsInSelectionRectangle always returns empty array...

GetActorsInSelectionRectangle always returns empty array…
& here is my code:

void ARTSHUDCanvas::OnStartSelection_Implementation()
{
	MouseFrom = UWidgetLayoutLibrary::GetMousePositionOnViewport(this) * UWidgetLayoutLibrary::GetViewportScale(this);
	bIsReceivingMouse = true;
}

void ARTSHUDCanvas::OnEndSelection_Implementation()
{
	if (bIsDrawingMarquee)
	{
		TArray<ARTSUnitBase*> OutActors;
		if (GetActorsInSelectionRectangle<ARTSUnitBase>(MouseFrom, MouseTo, OutActors))//, false, false))
		{
			if (OutActors.Num() > 0)
			{
				ARTSPlayerState* StateRef = GetOwningPlayerController()->GetPlayerState<ARTSPlayerState>();
				for (ARTSUnitBase* EachUnit : OutActors)
				{
					StateRef->AddUnitToSelection(EachUnit);
				}
			}
		}
		bIsDrawingMarquee = false;
	}
	bIsReceivingMouse = false;
}

void ARTSHUDCanvas::DrawHUD()
{
	if (bIsReceivingMouse)
	{
		UpdateSelection(UWidgetLayoutLibrary::GetMousePositionOnViewport(this) * UWidgetLayoutLibrary::GetViewportScale(this));
	}
}

void ARTSHUDCanvas::UpdateSelection(FVector2D InMouse)
{
	if (bIsDrawingMarquee)
	{
		MouseTo = InMouse;
		DrawRect(RectColor, MouseFrom.X, MouseFrom.Y, MouseTo.X - MouseFrom.X, MouseTo.Y - MouseFrom.Y);
		//TODO: preselection highlights
	}
	else
		bIsDrawingMarquee = FVector2D::Distance(MouseFrom, InMouse) > 10.f;
}

I tried replacing my custom ARTSUnitBase with AActor, to ensure it works, but still receiving an empty array.

EDIT: Also receiving a warning message when drawing marquee, Canvas draw functions only in DrawHud, but i move all code inside DrawHud() and still warns me.

Hey @ManOguaR
It could be an issue of your function only wanting to detect full encapsulation of the marquee’d object, I think that is the default of the program: “Actor Must Be Fully Enclosed.” You may want to specify that you want everything that intersects the marquee.
How are you calling the function to run this code here?
-Zen

Sorry @ZenLeviathan, but that was not the problem, that strange warning was the key. I decided to continue implementing selection previewing, while some answer comes… And then, moving GetActorsInSelectionRectangle call to UpdateSelection() function, all works, and no warnings at all.

You must do draw calls under DrawHUD() including those who are invisible, like GetActorsInSelectionRectangle(…) to get them working properly. Maybe the HUD drawing is caching its own processor time and consuming jobs like GetActorsInSelectionRectangle(…) are adding overhead or have no direct memory access if called within-from other scenarios, like events or…?

i guess :stuck_out_tongue:

@ManOguaR
My mistake, I’m glad you got it to work though.
Let me know if you have any more issues, and happy developing!
-Zen :vulcan_salute: