Tries to place the box on the flat and free surface.
First, this method aligns the box with the flat surface: box.forward is aligned with the surface normal, box.up is aligned with upwards .
Then it checks if the box can fit the environment by checking collisions.
ParametersrayThe desired direction of placement. The common use case is to construct this ray with:
new Ray(controllerTransform.position, controllerTransform.forward)
boxSizeSize of the box in local-space coordinates. Width is aligned with the local x-axis, height is aligned with the local y-axis, length is aligned with the local z-axis.
'x' and 'y' components should be greater than EnvironmentDepthManagerRaycastExtensions.MinXYSize to correctly determine the surface normal.
'z' component can be zero for flat objects.
upwardsThe local y-axis of the box is aligned with upwards vector before checking for collisions with the environment.
hitContains the placement result. Example of how to apply the pose to the object:
transform.SetPositionAndRotation(hit.point, Quaternion.LookRotation(hit.normal, upwards));
Returns'true' only if the surface is flat, free of clutter and big enough to fit the dimensions of the box.