Is there a scale-independent version of Transform.TransformPoint?
I am trying to convert a position to a localized position relative to an object, and then round that position. The problem is that with the scale dependent Transform.TransformPoint method, the position is rounded to fractions of the object's scale instead of to an absolute distance away from the center of the object. Any help would be appreciated, thanks.
My current code:
// makes the point's position local to the gameobject that was hit by the raycast
tTemp.position = hit.collider.gameObject.transform.InverseTransformPoint(hit.point);
// rounds it to the apropriate amount
tTemp.position = new Vector3
(
Mathf.Round(tTemp.position.x * gridSize)/gridSize,
Mathf.Round(tTemp.position.y * gridSize)/gridSize,
Mathf.Round(tTemp.position.z * gridSize)/gridSize
);
// translates the position back into world space
tTemp.position = hit.collider.gameObject.transform.TransformPoint(tTemp.position);
↧