From a33af23270dfebafd946e8d1382a24df3c44890d Mon Sep 17 00:00:00 2001 From: SpoodyTheOne Date: Sun, 4 Feb 2024 03:25:01 +0100 Subject: [PATCH] Playro dmange and gmage mananger --- Assets/Resources/Player1.prefab | 74 +++++++++++++------------ Assets/Resources/Player2.prefab | 74 +++++++++++++------------ Assets/Scenes/GameScene.unity | 22 +++++++- Assets/Scripts/Player/PlayerMovement.cs | 5 +- 4 files changed, 101 insertions(+), 74 deletions(-) diff --git a/Assets/Resources/Player1.prefab b/Assets/Resources/Player1.prefab index 7b17070..6883098 100644 --- a/Assets/Resources/Player1.prefab +++ b/Assets/Resources/Player1.prefab @@ -11,7 +11,6 @@ GameObject: - component: {fileID: 1930891210259786141} - component: {fileID: 2669453284189978930} - component: {fileID: 8069942137008974672} - - component: {fileID: 1842047609192968100} m_Layer: 7 m_Name: Renderer m_TagString: Untagged @@ -107,41 +106,6 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 ---- !u!58 &1842047609192968100 -CircleCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1936012740462134995} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 192 - m_LayerOverridePriority: 0 - m_ForceSendLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ForceReceiveLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ContactCaptureLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_CallbackLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - serializedVersion: 2 - m_Radius: 0.5 --- !u!1 &2470138561869876166 GameObject: m_ObjectHideFlags: 0 @@ -274,6 +238,7 @@ GameObject: - component: {fileID: 1749848915408613053} - component: {fileID: 1949941092232239315} - component: {fileID: 1449424410418603396} + - component: {fileID: 3467400445075357762} m_Layer: 7 m_Name: Player1 m_TagString: Player @@ -331,7 +296,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -441,6 +408,41 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!58 &3467400445075357762 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 192 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 0.5 --- !u!1001 &6225877037457186740 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index 889c005..380df09 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -11,7 +11,6 @@ GameObject: - component: {fileID: 1930891210259786141} - component: {fileID: 2669453284189978930} - component: {fileID: 8069942137008974672} - - component: {fileID: 1842047609192968100} m_Layer: 7 m_Name: Renderer m_TagString: Untagged @@ -107,41 +106,6 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 ---- !u!58 &1842047609192968100 -CircleCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1936012740462134995} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 192 - m_LayerOverridePriority: 0 - m_ForceSendLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ForceReceiveLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ContactCaptureLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_CallbackLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - serializedVersion: 2 - m_Radius: 0.5 --- !u!1 &3096169748286405671 GameObject: m_ObjectHideFlags: 0 @@ -190,6 +154,7 @@ GameObject: - component: {fileID: 7071433868121438663} - component: {fileID: 1949941092232239315} - component: {fileID: 7729933180365677331} + - component: {fileID: 5090706458114509519} m_Layer: 7 m_Name: Player2 m_TagString: Player @@ -247,7 +212,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -357,6 +324,41 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!58 &5090706458114509519 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 192 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 0.5 --- !u!1 &7787472247078384126 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 260bc94..b575dc9 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -3294,6 +3294,23 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1655073753 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} + m_PrefabInstance: {fileID: 1683288374126251321} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1655073756 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1655073753} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cfcb795658e5b9d8bbbf6d6e238c21a0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1677146148 GameObject: m_ObjectHideFlags: 0 @@ -3808,7 +3825,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} + insertIndex: -1 + addedObject: {fileID: 1655073756} m_SourcePrefab: {fileID: 100100000, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} --- !u!1001 &4910321061857220295 PrefabInstance: diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 27e8a5f..22d41d6 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -109,8 +109,11 @@ public class PlayerMovement : MonoBehaviour void OnCollisionStay2D(Collision2D collision) { - if (collision.otherCollider.gameObject.CompareTag("Enemy")) + Debug.Log("Hit other " + collision.otherCollider.gameObject.name); + Debug.Log("Hit other " + collision.collider.gameObject.name); + if (collision.collider.gameObject.CompareTag("Enemy")) { // Other object is an enemy + Debug.Log("Hit enememenemy"); hp.TakeDamage(1f); } }