Why is there delay for controller / VR input?

Why whenever I press any buttons on my VR controller, it gets registered about half a second later? Roblox is the only game having this delay.
Example:

Script (If interested)
userInputService = game:GetService("UserInputService")

controllerLeft = workspace.Controllers.Quest2Left
controllerRight = workspace.Controllers.Quest2Right

hitboxes = {workspace.Controllers.Quest2Left.Hitbox, workspace.Controllers.Quest2Right.Hitbox}
pickups = workspace.Pickups:GetChildren()
holding = {nil, nil}

-- Grip      = ButtonR1 and ButtonL1
-- Trigger = ButtonR2 and ButtonL2
-- Stick     = ButtonR3 and ButtonL3

function pickUp(controller) -- 1 = Left, 2 = Right
	print("pickUp() called for controller", controller)

	local overlaps = workspace:GetPartBoundsInBox(hitboxes[controller].CFrame, hitboxes[controller].Size)

	for _,v in pairs(overlaps) do
		if table.find(pickups, v) then

			if controller == 1 and holding[2] == v then holding[2] = nil
			elseif controller == 2 and holding[1] == v then holding[1] = nil
			end
			
			v.Anchored = true
			v.Color = Color3.new(0.333333, 1, 1)
			holding[controller] = v
			v.Parent = hitboxes[controller].Parent
			
			break
		end
	end
end

function drop(controller) -- 1 = Left, 2 = Right
	print("drop() called for controller", controller)
	
	local object = holding[controller]
	if object then
		
		object.Color = Color3.new(1, 1, 1)
		object.Anchored = false
		object.Parent = workspace.Pickups
		
	end
end

userInputService.InputBegan:Connect(function(input)
	print(input.KeyCode)
	if input.KeyCode == Enum.KeyCode.ButtonL1 then
		pickUp(1) -- 1 = Left, 2 = Right
	elseif input.KeyCode == Enum.KeyCode.ButtonR1 then
		pickUp(2) -- 1 = Left, 2 = Right
	end
end)

userInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.ButtonL1 then
		drop(1) -- 1 = Left, 2 = Right
	elseif input.KeyCode == Enum.KeyCode.ButtonR1 then
		drop(2) -- 1 = Left, 2 = Right
	end
end)
1 Like

Currently can’t see much of an issue but I’d say this could be a connection issue?
Are your VR controllers wireless? Are items being picked up on the server/client?

Lag can appear almost anywhere if there is any sort of connection.
Could be that you’re picking up a item on the client but the server has to make the player the network owner first before they can interact with said physics object.

Could be that (if using wireless VR) it takes a few microseconds for the signal to reach your computer and then get processed in the game.

I doubt if the script has any sorts of bad performance, you could try to monitor connections/latency and see what the results are there.

The only input that has this latency issue is the VR controller’s grip and trigger button, the A, B, Y or X button work fine without noticeable latency. It’s much more noticeable when playing the game than on the video tho.
I have to hold down the trigger / grip button for a short time, if I press it and let go immediately the input doesn’t even get registered.

I know for a fact that some triggers have analog input
(meaning that their input isn’t just 0 and 1 like A/B/X/Y but can also be something in between, joysticks on controllers are also analog).

It could be that your controller only detects input when the trigger is let’s say… 80% pressed.

There is a way to detect how far a trigger is pressed down in Roblox (assuming the trigger is analog).

If I remember well this was done through a InputObject.Position property?
The same way you read the mouse delta/position or joystick position with UserInputService can be used to detect trigger position.

I experimented with the InputBegan, InputEnded and InputChanged events, and my result was really confusing;
InputBegan isn’t fired when I press the trigger / grip for a short time, InputEnded however does, with a delay.
I’m bad at explaining so heres a video:
https://drive.google.com/file/d/16tYSBjMiNyyABUFcSiFR5fY1rYWL5NJv/view?usp=sharing

1 Like