I need to make a system in which objects overlap each other, but for some reason only 1x1x1 objects work, if another object has a size of 1x0.3x1, overlap and intersection occur
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 10000f,layerMask))
{
pos = hit.point + hit.normal * shift;
}
if (pendingObj != null && isGrid)
{
Bounds penBounds = pendingObj.GetComponent<MeshRenderer>().bounds;
//shift = pendingObj.transform.localScale.y/2;
pendingObj.transform.position = new Vector3(RoundToNearestGrid(pos.x), /*hit.point.y/* + */RoundToNearestGrid(pos.y + penBounds.extents.y), RoundToNearestGrid(pos.z ));
//pendingObj.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
if (Input.GetMouseButtonDown(0) && canPlace)
{
PlaceObject();
}
if (Input.GetKeyDown(KeyCode.R))
{
RotateObject();
}
}
else
{
return;
}