Question by
therealFrEiz · May 08, 2017 at 06:36 AM ·
mousemathfmouse positionroundingrounding-errors
Rounding position with mouse constant update
I'm making a mario maker style game where everything has to snap to a grid. I want to, while I'm dragging it, have the item snap into place closest to each int.
void FixedUpdate () {
Vector2 pos = Input.mousePosition;
pos.x = Mathf.Round(pos.x);
pos.y = Mathf.Round(pos.y);
pos = Camera.main.ScreenToWorldPoint (pos);
transform.position = pos;
}
This does not work for me, and I've been trying for hours to fix this. Nothing has helped so far, I've gone through every forum I could find to no avail. Please help!!
Comment
Answer by vovivoh2007 · May 28 at 06:50 AM
After 5 years, none has answered, still have the same issue because I think I do.
Your answer
Follow this Question
Related Questions
How do i stop Vector3 from rounding? 1 Answer
how to make flashlight follow mouse pointer in 2D? 1 Answer
How to control global mouse 0 Answers
,Know if the mouse position has changed 0 Answers