Hi, i am trying to get the radius of a square so that an object can be placed a certain distance away from the square. I have this but it does not work:
There are a number of different ways you can get the dimensions of your hit object, varying in accuracy:
Assuming the object is a perfect Cube you can take the lossyScale/localScale of the transform as its world dimensions (e.g scale 10x10x10 would be a cube of side 10).
Since you’re using rays already, we can take the collider of the target GameObject and look at the bounding box for dimensions.
You could even get the MeshFilter from the target GameObject and get the bounds from the Mesh