- Home /
Height of rotated Objects to snap them
Hi, im working on a system to snap objects to other objects under them. Actually it works very great until i rotate the objects.
if (Physics.Raycast (transform.position, -Vector3.up, out hit))
{
transform.position = hit.point + new Vector3(0f,(float)transform.lossyScale.y /2f,0f);
}
how can i get the new height of an object that is random rotated? Or have u an other idea how to solve the snap problem?
Zoxlike
Comment
Answer by ZoXlike · Jun 16, 2017 at 12:20 PM
Ok i found a solution by myself :D
if (Physics.Raycast (transform.position, -Vector3.up, out hit))
{
transform.position = hit.point + new Vector3(0f,(float)GetComponent<Renderer>().bounds.size.y /2f,0f);
}
fits the problem
/close