I am building a radial menu that is compatible with gamepads, the idea is to use the left thumbstick (Thumbstick1) to navigate the menu.
At the moment the character runs around if you interact with the menu since I do not know how to sink the Thumbstick1 input event.
Image of the work in progress radial to give a more clear picture:
The thumbstick input handling code for the radial menu:
UserInputService.InputChanged:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Thumbstick1 and
input.Position.Magnitude > THUMBSTICK_DEADZONE and
radialMenu.Enabled then
local degrees = thumbStickVectorToDegrees(input.Position.X, input.Position.Y)
if degrees then
highlightButton(degrees)
end
end
end)
Is there any method to sink the input event from a thumbstick in order to prevent the character from moving when using a controller?
I would prefer not to mess around with the walk speed of the character or similar since that would be too hacky.
I’m pretty sure ContextActionService will sink joystick input (and keyboard input) and stop movement if you use BindAction with the various input types, until you use UnbindAction. Something like this
Thanks! It worked like a charm, I do not know why I ended up staring myself blind at the UserInputService when I use the ContextService to bind and sink inputs at a million other places.
The code ended up like:
ContextActionService:BindActionAtPriority(
"RadialMenu_Navigate",
function(actionName, inputState, input)
if not radialMenu.Enabled then
return Enum.ContextActionResult.Pass
end
if input.Position.Magnitude > THUMBSTICK_DEADZONE then
local degrees = thumbStickVectorToDegrees(input.Position.X, input.Position.Y)
if degrees then
highlightButton(degrees)
end
end
return Enum.ContextActionResult.Sink
end,
false,
Enum.ContextActionPriority.High.Value + 1,
Enum.KeyCode.Thumbstick1
)