Hi I am trying to figure out how to get my building to snap to a grid when I move it around. Right now it follows my mouse position just fine, but I can’t get it to snap. Please help!
private Vector3 temp;
// Update is called once per frame
void Update () {
temp.x = Mathf.Round(Input.mousePosition.x);
temp.y = Mathf.Round(Input.mousePosition.y);
temp.z = Camera.main.transform.position.y - 0.5f;
transform.position = Camera.main.ScreenToWorldPoint(temp);
I just need the x and y to snap, the z position is just fine. Thanks!