Fixed radial menu input

This commit is contained in:
olehhapuk
2026-05-25 23:13:25 +03:00
parent ca3c81ada8
commit e4cc9ee66c
8 changed files with 131 additions and 10 deletions
@@ -4,6 +4,7 @@
#include "RadialMenuWidget.h"
#include "GameFramework/PlayerController.h"
#include "Kismet/GameplayStatics.h"
#include "Blueprint/WidgetLayoutLibrary.h"
URadialMenuController::URadialMenuController()
{
@@ -184,8 +185,25 @@ void URadialMenuController::UpdateHoverFromInput()
return;
}
UpdateHoverFromDirection(DirX, DirY, FVector2D(DirX, DirY).Size());
}
void URadialMenuController::UpdateHoverFromDirection(float DirX, float DirY, float Magnitude)
{
if (!bIsOpen)
{
return;
}
// Below the dead zone we keep the current hover rather than deselecting,
// so releasing the stick to neutral doesn't clear the player's choice.
if (Magnitude < SelectionDeadZone)
{
return;
}
// Angle clockwise from straight up (12 o'clock), in [0,360).
// atan2(x, y) gives angle from +Y axis turning toward +X = clockwise. Nice.
// atan2(x, y) gives angle from +Y axis turning toward +X = clockwise.
float AngleDeg = FMath::RadiansToDegrees(FMath::Atan2(DirX, DirY));
if (AngleDeg < 0.f)
{