Mouse Behavior lockcenter is different on PC and console controls

So i figured i’d add controller support early on in my latest project, and I’ve run into a bit of an issue.

when MouseBehavior is set to LockCenter, it’s in the screen’s center on PC, but about 3/4ths up the screen on console.

gif:
https://i.gyazo.com/efb3c95b76b0d9310a30bfe04e287d34.gif

this creates a problem, as it might give one platform an advantage over the other.
is there a way to force it to be one or the other? (preferably on the 3/4ths up one)

2 Likes

Encountered this as well. Really strange and doesn’t seem to serve any purpose.

If you want it to be always centered, you will have to disable the cursor (Documentation - Roblox Creator Hub) and put the cursor image as an ImageLabel in the center of the screen.

1 Like

right, ok.
but i need the mouse cursor for tool reference, or get where the center cursor is pointing…
how would i get that?

Raycasting from Camera.CFrame.p in the direction of Camera.CFrame.lookVector * 1000 should work.

1 Like

well, i wanted to get that 3/4ths up position (from the controller cursor position)
but, it seems i can use ScreenPointToRay for that.

local function castMouse(ignoreList)
	local mousePos = UserInputService:GetMouseLocation()
	local ray = workspace.CurrentCamera:ViewportPointToRay(mousePos.X, mousePos.Y)
	ray = Ray.new(ray.Origin, ray.Direction*5000)
	return workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
end

Swap out GetMouseLocation for the middle of the viewport for gamepads.

1 Like

This is a bug that used to happen on PC too but not as much, I’m not sure if it happens anymore, but placing an imagelabel in the middle wouldn’t fix it as Mouse.Hit would still be way above the middle of the screen making the bullets not accurate.

He stated a workaround for it;