Fix prefab pivot and advancing on furnitureMover

This commit is contained in:
Legonzaur 2023-01-23 16:59:00 +01:00
parent a458ca5f57
commit 4f64ca28fd
10 changed files with 326 additions and 17 deletions

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &392586589562003607
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6114432350300135443}
- component: {fileID: 8817835740557246532}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6114432350300135443
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 392586589562003607}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3674349604157782260}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &8817835740557246532
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 392586589562003607}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 12.237078, y: 6.518132, z: 9.380431}
m_Center: {x: 0.1100985, y: 3.444804, z: -0.26158008}
--- !u!1 &1253093426770874476
GameObject:
m_ObjectHideFlags: 0
@ -152,6 +197,7 @@ GameObject:
m_Component:
- component: {fileID: 3674349604157782260}
- component: {fileID: 7152506842566364840}
- component: {fileID: 5516512649396120673}
m_Layer: 0
m_Name: Simple table
m_TagString: Untagged
@ -174,6 +220,7 @@ Transform:
- {fileID: 7846351332623750186}
- {fileID: 705425444331171642}
- {fileID: 5160726694365660193}
- {fileID: 6114432350300135443}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -193,6 +240,22 @@ MonoBehaviour:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!54 &5516512649396120673
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4158574887593288270}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &6146061087085142095
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3884115040606308642
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6821231163936271320}
- component: {fileID: 6695299937866651750}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6821231163936271320
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3884115040606308642}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5262755222010251265}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &6695299937866651750
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3884115040606308642}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.568707, y: 7.746119, z: 5.480494}
m_Center: {x: -0.1474282, y: 4.3566036, z: -0.06824057}
--- !u!1 &8231086993610971755
GameObject:
m_ObjectHideFlags: 0
@ -278,6 +323,26 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7310167259df75745b825087bf4c8de0, type: 3}
m_Name:
m_EditorClassIdentifier:
combinedBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!54 &5577736131529907943
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4774624094512517819}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!4 &5035235579416466379 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 820629935725706273, guid: 61dd8047e5e66dc4db5c150abe38beae, type: 3}

View File

@ -260,6 +260,7 @@ GameObject:
- component: {fileID: 2996515769384266075}
- component: {fileID: 2709258200819239477}
- component: {fileID: 6645681851711596344}
- component: {fileID: 1547886741423616364}
m_Layer: 0
m_Name: shelf_empty
m_TagString: Untagged
@ -288,6 +289,7 @@ Transform:
- {fileID: 1696234186987782576}
- {fileID: 2781697966167280641}
- {fileID: 5613503160827514234}
- {fileID: 5878205338461874499}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
@ -306,6 +308,7 @@ MonoBehaviour:
combinedBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!65 &6645681851711596344
BoxCollider:
m_ObjectHideFlags: 0
@ -319,6 +322,22 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 2.017374, y: 1.4093293, z: 4.320848}
m_Center: {x: -0.0065603256, y: 0.012041539, z: 2.1498158}
--- !u!54 &1547886741423616364
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2512467202128557025}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &2602268122132683364
GameObject:
m_ObjectHideFlags: 0
@ -568,6 +587,51 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &4588887904168053738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5878205338461874499}
- component: {fileID: 9184669346505142783}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5878205338461874499
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4588887904168053738}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2996515769384266075}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &9184669346505142783
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4588887904168053738}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.9363493, y: 1.3597183, z: 4.2336807}
m_Center: {x: -0.016334474, y: 0.029815674, z: 2.1933994}
--- !u!1 &4983300697117577925
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &451019611259114879
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2833408188615038500}
- component: {fileID: 777966934955362417}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2833408188615038500
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451019611259114879}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 589337997038399236}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &777966934955362417
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451019611259114879}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 40.602814, y: 20.834862, z: 1.929568}
m_Center: {x: 0.19675513, y: 8.908121, z: -1.2512306}
--- !u!1 &2835658414891243653
GameObject:
m_ObjectHideFlags: 0
@ -30,6 +75,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6063464173187445548}
- {fileID: 2833408188615038500}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -14688,6 +14688,14 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 90
objectReference: {fileID: 0}
- target: {fileID: 9082827438125951081, guid: ab468a82ad445da4e9a084297505261f, type: 3}
propertyPath: m_LocalPosition.x
value: -0.009
objectReference: {fileID: 0}
- target: {fileID: 9082827438125951081, guid: ab468a82ad445da4e9a084297505261f, type: 3}
propertyPath: m_LocalPosition.y
value: 0.8
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ab468a82ad445da4e9a084297505261f, type: 3}
--- !u!4 &802860442 stripped
@ -22509,6 +22517,11 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7304097665698855045, guid: 7520016a817d68f4685d157d457ebed1, type: 3}
m_PrefabInstance: {fileID: 1569982188}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1573644873 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2835658414891243653, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3}
m_PrefabInstance: {fileID: 1989420947}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1582617698
PrefabInstance:
m_ObjectHideFlags: 0
@ -28197,7 +28210,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1888977163}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.077, y: -0.821, z: 1.791}
m_LocalPosition: {x: 0.077, y: -0.821, z: 1.691}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -30181,6 +30194,22 @@ Transform:
m_CorrespondingSourceObject: {fileID: 589337997038399236, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3}
m_PrefabInstance: {fileID: 1989420947}
m_PrefabAsset: {fileID: 0}
--- !u!54 &1989420950
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1573644873}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1001 &2030655353
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -77,6 +77,11 @@ public class FurnitureMover : MonoBehaviour
Ray SnapRaycast = new Ray(transform.position, transform.forward);
RaycastHit SnapHit;
//TODO Check if object is on walls
if (Grabbing.wallMount)
{
}
bool SnapbHit = Physics.Raycast(SnapRaycast, out SnapHit, 100f, AutoPlacementEnvironmentMask);
if (SnapbHit && Grabbing != null)

View File

@ -8,6 +8,7 @@ public class MovableFurniture : Furniture
private Rigidbody _rigidbody;
public bool wallMount;
private bool isColliding = false;
// Start is called before the first frame update
new void Start()
{
@ -22,7 +23,7 @@ public class MovableFurniture : Furniture
var outline = child.gameObject.AddComponent<ObjectOutline>();
if (!outline) continue;
outlines.Add(outline);
outline.OutlineMode = ObjectOutline.Mode.OutlineAll;
outline.OutlineMode = ObjectOutline.Mode.OutlineVisible;
outline.OutlineColor = Color.yellow;
outline.OutlineWidth = 5f;
outline.enabled = false;
@ -59,7 +60,7 @@ public class MovableFurniture : Furniture
/*child.OutlineMode = ObjectOutline.Mode.OutlineAll;
child.OutlineColor = Color.yellow;
child.OutlineWidth = 5f;*/
outline.enabled = true;
//outline.enabled = true;
}
}
@ -67,7 +68,7 @@ public class MovableFurniture : Furniture
{
foreach (ObjectOutline outline in outlines)
{
outline.enabled = false;
//outline.enabled = false;
}
}
@ -96,7 +97,7 @@ public class MovableFurniture : Furniture
{
Vector3 previousPosition = transform.position;
Vector3 offset = Vector3.zero;
//if (isColliding) { return; }
transform.position = position;
return;
if (wallMount)
@ -166,17 +167,40 @@ public class MovableFurniture : Furniture
outline.enabled = false;
}
}
}
private void OnCollisionEnter(Collision collision)
//Check if collision before moving an object
public void OnFurnitureCollisionEnter(Collider other)
{
Debug.Log("collisionEnter");
/*foreach (ObjectOutline outline in outlines)
{
outline.OutlineColor = Color.red;
outline.enabled = true;
}
isColliding = true;*/
}
private void OnCollisionExit(Collision collision)
public void OnFurnitureCollisionStay(Collider other)
{
Debug.Log("collisionExit");
//isColliding = true;
}
public void OnFurnitureCollisionExit(Collider other)
{
//Run CheckFurnitureCollisions on next FixedUpdate loop. If no object is truly colliding, isColliding should be false inside CheckFurnitureCollisions
/*Invoke("CheckFurnitureCollisions", Time.fixedTime * 2);
isColliding = false;*/
}
private void CheckFurnitureCollisions()
{
if (isColliding == true) return;
foreach (ObjectOutline outline in outlines)
{
outline.OutlineColor = Color.yellow;
outline.enabled = false;
}
}
}

View File

@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MovableFurniturePart : MonoBehaviour
{
@ -9,13 +6,13 @@ public class MovableFurniturePart : MonoBehaviour
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnPointerClickDown()
@ -32,4 +29,19 @@ public class MovableFurniturePart : MonoBehaviour
{
parent.OnPointerExit();
}
private void OnTriggerEnter(Collider other)
{
parent.OnFurnitureCollisionEnter(other);
}
private void OnTriggerExit(Collider other)
{
parent.OnFurnitureCollisionExit(other);
}
private void OnTriggerStay(Collider other)
{
parent.OnFurnitureCollisionStay(other);
}
}

View File

@ -18,7 +18,7 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: 7fffffff7fffffff7fffffffffffffff7fffffff7fffffff7fffffff88ffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffff
m_LayerCollisionMatrix: 7ffdffff7ffdffff7ffdffffffffffff7ffdffff7ffdffff7ffdffff88fdff7fffffffff08ffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffdffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1

View File

@ -7,6 +7,7 @@ TagManager:
- SamplesInfoPanel
- projectile
- FxTemporaire
- FurnitureTrigger
layers:
- Default
- TransparentFX
@ -17,7 +18,7 @@ TagManager:
- Static Lighting
- Teleport Area
- Environment
-
- FurnitureTrigger
-
-
-