Quantcast
Channel: Questions in topic: "transform.transformpoint"
Viewing all articles
Browse latest Browse all 29

Version of Transform.TransformPoint which is unaffected by scale?

$
0
0
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);

Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>