From fd0aa415dab25cda4998c0aaa159a829e86fd6e9 Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Fri, 5 Jun 2020 14:49:25 -0400 Subject: [PATCH] Reworked collision detection so it doesn't break if the mouse moves too fast and cleaning items don't sproadically shake when collision gets funky --- Assets/Prefabs/CleanerFluid.prefab | 2 +- Assets/Prefabs/Dirt.prefab | 2 +- Assets/Scenes/Main Scene.unity | 12 ++++++------ Assets/Scripts/DirtScript.cs | 4 ++-- Assets/Scripts/SprayScript.cs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Assets/Prefabs/CleanerFluid.prefab b/Assets/Prefabs/CleanerFluid.prefab index 3dd703e..98975df 100644 --- a/Assets/Prefabs/CleanerFluid.prefab +++ b/Assets/Prefabs/CleanerFluid.prefab @@ -105,7 +105,7 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: 0, y: 0} diff --git a/Assets/Prefabs/Dirt.prefab b/Assets/Prefabs/Dirt.prefab index bcbe646..f506002 100644 --- a/Assets/Prefabs/Dirt.prefab +++ b/Assets/Prefabs/Dirt.prefab @@ -106,7 +106,7 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: 0, y: 0} diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index b975409..f5a6e1f 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -423,8 +423,8 @@ GameObject: m_Component: - component: {fileID: 1739945071} - component: {fileID: 1739945070} - - component: {fileID: 1739945073} - component: {fileID: 1739945072} + - component: {fileID: 1739945073} m_Layer: 0 m_Name: SprayBottle m_TagString: Item @@ -593,7 +593,7 @@ Rigidbody2D: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1739945069} - m_BodyType: 0 + m_BodyType: 1 m_Simulated: 1 m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 @@ -604,7 +604,7 @@ Rigidbody2D: m_Material: {fileID: 0} m_Interpolate: 0 m_SleepingMode: 1 - m_CollisionDetection: 0 + m_CollisionDetection: 1 m_Constraints: 0 --- !u!1 &1885377150 GameObject: @@ -616,8 +616,8 @@ GameObject: m_Component: - component: {fileID: 1885377152} - component: {fileID: 1885377151} - - component: {fileID: 1885377154} - component: {fileID: 1885377153} + - component: {fileID: 1885377154} m_Layer: 0 m_Name: Rag m_TagString: Item @@ -810,7 +810,7 @@ Rigidbody2D: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1885377150} - m_BodyType: 0 + m_BodyType: 1 m_Simulated: 1 m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 @@ -821,5 +821,5 @@ Rigidbody2D: m_Material: {fileID: 0} m_Interpolate: 0 m_SleepingMode: 1 - m_CollisionDetection: 0 + m_CollisionDetection: 1 m_Constraints: 0 diff --git a/Assets/Scripts/DirtScript.cs b/Assets/Scripts/DirtScript.cs index 5e6e16b..cf730ca 100644 --- a/Assets/Scripts/DirtScript.cs +++ b/Assets/Scripts/DirtScript.cs @@ -10,7 +10,7 @@ public class DirtScript : MonoBehaviour private int wiped = 0; Color tmp; - void OnCollisionEnter2D(Collision2D other){ + void OnTriggerEnter2D(Collider2D other){ if(other.gameObject.name == "SprayBottle" && !sprayed) { @@ -20,7 +20,7 @@ public class DirtScript : MonoBehaviour } - void OnCollisionExit2D(Collision2D other){ + void OnTriggerExit2D(Collider2D other){ tmp = this.GetComponent().color; diff --git a/Assets/Scripts/SprayScript.cs b/Assets/Scripts/SprayScript.cs index f0d556b..4bbfead 100644 --- a/Assets/Scripts/SprayScript.cs +++ b/Assets/Scripts/SprayScript.cs @@ -8,7 +8,7 @@ public class SprayScript : MonoBehaviour private int wiped = 0; Color tmp; - void OnCollisionExit2D(Collision2D other){ + void OnTriggerExit2D(Collider2D other){ tmp = this.GetComponent().color;