try furniture movement but not working

This commit is contained in:
Axel Galand 2023-01-18 16:22:23 +01:00
parent 518e6d2137
commit 002e7278a1
2 changed files with 15 additions and 6 deletions

View File

@ -100,13 +100,8 @@ public class Catalog : MonoBehaviour
furrnitureBall.transform.localScale *= rescale;
furrnitureBall.transform.localPosition = Vector3.down * 0.2f;
sphere.SetActive(true);
<<<<<<< Updated upstream
//hand.GetGrabStarting
hand.AttachObject(sphere, GrabTypes.Trigger);
=======
//hand.GetGrabStarting
hand.AttachObject(sphere, GrabTypes.Trigger);
>>>>>>> Stashed changes
currentSphere = sphere;
}

View File

@ -98,7 +98,21 @@ public class MovableFurniture : Furniture
if (wallMount)
{
transform.position = position;
Bounds objectBounds = GetComponent<Collider>().bounds;
// check if object has objectBounds, if not combine the bounds of its children
Bounds objectBounds;
if (combinedBounds == null)
{
objectBounds = new Bounds();
foreach (Transform child in children)
{
objectBounds.Encapsulate(child.GetComponent<Renderer>().bounds);
}
}
else
{
objectBounds = (Bounds)combinedBounds;
}
Vector3 objectSize = objectBounds.size;
offset = new Vector3(objectSize.x / 2, objectSize.y / 2, objectSize.z / 2);
Collider[] colliders = Physics.OverlapBox(transform.position + offset, offset, transform.rotation, layerMask);