This moves my player directly on my mouse position with float coordinates, not rounding it to int. I tried both Mathf.Round and Mathf.RoundToInt. Is there a simple fix for this code or am I doing it completely wrong?
Input.mousePosition already are intergers, so there’s no point in rounding them.
What’s the middle of a 2D square area you’re talking about?
Is it a gameObject or a theoretical grid system you’re trying to make work?
The solution to your problem would be rounding the worldPosition instead of the mousePosition.
player.gameObject.transform.position = new Vector3(Mathf.Round(worldPosition.x), Mathf.Round(worldPosition.y), worldPosition.z);