I am trying to find if there is a float value somewhere where I can see how much a player has pressed a button on a controller since this is natively supported, hardware wise, with all roblox compatible controllers. Specifically I need to know how far the triggers are pulled. I know roblox is capable of reading these things as the vehicle seat has a float value output for throttle and steering that my controller can manipulate properly. However, I can not find/edit the vehicle seat control code to remap the keys or see how they’re reading the controller output to get these floats.
Yes you can; it’s the position of the trigger similar to mouse position using the UserInputService. The position will always return a number between 0 and 1 on the z axis for how “pressed” the trigger is. Example:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonR1 then
print(input.Position.Z)
end
end
end)
7 Likes
If you want to see the values of the gamepads triggers you have to use the “R2” and “L2” buttons, not R1 or L1.
Here’s the example you provided with the correct button:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonR2 then
print(input.Position.Z)
end
end
end)