Mouse.X/Y out of sync with Input.Position.X/Y when using Touch controls

Since touch events (on mobile) also raise Mouse events (for legacy reasons I assume), my code made the assumption that mouse.X/Y and Input.Position.X/Y would always be the same after a given InputBegan/Changed/End event.

I had a bug that was caused by this not being the case.

To get a variety of input modes working in the same game I have had to use InputBegan/Changed/End exclusively, trapping each control modality separately (game pad, mouse, touch). This has had the least weird edge cases for me and is how I think the wiki should suggest future games do it.

I believe the Mouse X/Y returns ‘screen space’ while Input.Position returns ‘viewport space’ - that or the other way around. Basically, one of them is taking the topbar into account while the other one isn’t.

1 Like

The documentation for InputObject doesn’t say one way or the other. Documentation - Roblox Creator Hub

But that is a good theory.

I think a small discrepancy in Y would not have caused the bug I was seeing however.

UPDATE: wait. I think you are right after all.