ContextActionService:BindAction in a tool blocks GamePad input, preventing camera movement

I have a tool that binds an action during the time that it’s equipped. For mouse input and touch input, it works as expected. But the behavior with a gamepad is wrong: as soon as you equip the tool, camera-control from the gamepad is blocked and does not reach the game.

I have attached a place file with a barebones set of tools to reproduce the issue. There are two tools, one named “Works” and one named “Breaks.” The only difference is that “Breaks” is supposed to listen for Gamepad input, whereas “Works” does not. Both tools bind a function that does nothing.

If you use a mouse as your input device you can equip either tool and continue moving your camera around. However, if you use a gamepad as your input device, as soon as you equip “Breaks” your camera will become locked and stop listening to your inputs.
Place1.rbxl (54.4 KB)

System Information:
Intel(R) Core™ i7-8700 CPU @ 3.20GHz
NVIDIA GeForce RTX 2070
16.0 GB Memory
XBOX Controller

Expected behavior

The camera behavior should be consistent between input methods for both tools.

2 Likes

Thanks for the report! I filed a ticket in our internal database and we’ll follow up when we have an update for you.

1 Like

Hi there, thanks for the report. I’ve taken a look and it looks like the difference is because our camera input system connects to ContextActionService for gamepad input and UserInputService for mouse/touch. We’re looking to unify the system under CAS soon. In the meantime, this error is because you’ve bound to ContextActionService and sunk the input by default. You can get around this by returning Enum.ContextActionResult.Pass. Also if you’d like more control over how your binding interact with PlayerScripts, I’d recommend looking into BindActionAtPriority which allows you to specify which order your code will run relative to camera and control which runs at Enum.ContextActionPriority.Medium.Value (2000)

tool.Equipped:Connect(function()
	contextActionService:BindActionAtPriority("CollectTool", function(actionName, inputState, inputObject)
		-- your code here
		return Enum.ContextActionResult.Pass
	end, false, Enum.ContextActionPriority.High.Value, Enum.UserInputType.Touch, Enum.UserInputType.MouseMovement, Enum.UserInputType.Gamepad1)	
end)
1 Like