Fixed radial menu input
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user