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!!
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
C# Mathf.Round Not Rounding Input.mouseposition 0 Answers
How to Instantiate from mouse pos? 0 Answers
getting maximum x and y values of mouse position 1 Answer
Problem with textures on round surfaces 0 Answers