Question by
fluxhackspro · Aug 17, 2016 at 08:29 AM ·
gameobjectpositionint
How to set a gameobjects position to always be a whole number (int)?
Hello i have a quick question regarding gameobjects positions. Is there a way to always set a gameobjects position to a whole number/int. Almost make it snap to a position. Thanks
Comment
Best Answer
Answer by fluxhackspro · Aug 17, 2016 at 08:42 AM
Found the right answear for anyone that is still wondering:
Vector3 a = BlockPosBuild.transform.position;
Vector3 b = new Vector3(Mathf.Floor(a.x), Mathf.Floor(a.y + 1), Mathf.Floor(a.z));
//this is the gameobject
BlockPosBuild.transform.position = b;