From 002e7278a1ba60c09bb81b9b9a42329fd53fa3c7 Mon Sep 17 00:00:00 2001 From: Axel Galand Date: Wed, 18 Jan 2023 16:22:23 +0100 Subject: [PATCH] try furniture movement but not working --- Assets/Scripts/Catalog.cs | 5 ----- Assets/Scripts/MovableFurniture.cs | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Catalog.cs b/Assets/Scripts/Catalog.cs index 02d752a..dbf9c14 100644 --- a/Assets/Scripts/Catalog.cs +++ b/Assets/Scripts/Catalog.cs @@ -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; } diff --git a/Assets/Scripts/MovableFurniture.cs b/Assets/Scripts/MovableFurniture.cs index 9e0996c..ae042ae 100644 --- a/Assets/Scripts/MovableFurniture.cs +++ b/Assets/Scripts/MovableFurniture.cs @@ -98,7 +98,21 @@ public class MovableFurniture : Furniture if (wallMount) { transform.position = position; - Bounds objectBounds = GetComponent().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().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);