diff --git a/Assets/Scenes/Cho môn AI/Only AI.unity b/Assets/Scenes/Cho môn AI/Only AI.unity index e20229a1..d9229eb3 100644 --- a/Assets/Scenes/Cho môn AI/Only AI.unity +++ b/Assets/Scenes/Cho môn AI/Only AI.unity @@ -41361,7 +41361,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: -8789529727683405701, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: notificationText @@ -41381,15 +41381,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.x - value: 18.23 + value: 10.72584 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.y - value: 10.363 + value: 6.58385 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.z - value: 42.18 + value: 17.501871 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.w @@ -41397,7 +41397,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.y @@ -41444,6 +41444,11 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} +--- !u!4 &241771775 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} + m_PrefabInstance: {fileID: 241771774} + m_PrefabAsset: {fileID: 0} --- !u!1 &282447033 GameObject: m_ObjectHideFlags: 0 @@ -46884,7 +46889,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -46892,15 +46897,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 2.6 + value: -4.90416 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 4.53 + value: 0.7508502 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 51.2 + value: 26.521872 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -46908,15 +46913,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -46978,6 +46983,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &310459322 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 310459319} + m_PrefabAsset: {fileID: 0} --- !u!1 &333057065 GameObject: m_ObjectHideFlags: 0 @@ -47002,8 +47012,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 333057065} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.62463, y: 13.27338, z: -19.50002} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -3.87953, y: 9.49423, z: -44.178146} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -47053,7 +47063,7 @@ Transform: - {fileID: 375187854} - {fileID: 1061793569} - {fileID: 1398230979} - m_Father: {fileID: 0} + m_Father: {fileID: 1625646592} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &333831099 GameObject: @@ -47435,12 +47445,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 348410791} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 5.7248, y: 1.5, z: -32.50002} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -1.7793598, y: -2.27915, z: -57.178146} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1625646592} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &365978100 GameObject: @@ -90060,7 +90070,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -90068,15 +90078,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: -8.9 + value: -16.40416 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 45.2 + value: 20.521872 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -90084,15 +90094,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -90154,13 +90164,18 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &570772204 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 570772201} + m_PrefabAsset: {fileID: 0} --- !u!1001 &572767392 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -90168,15 +90183,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 9.72 + value: 2.2158403 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 15.75 + value: -8.928129 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -90184,15 +90199,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -90222,6 +90237,11 @@ PrefabInstance: insertIndex: -1 addedObject: {fileID: 1665376262} m_SourcePrefab: {fileID: 100100000, guid: 15df559ce497e104a81254e0adf3107e, type: 3} +--- !u!4 &572767393 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 572767392} + m_PrefabAsset: {fileID: 0} --- !u!43 &593490377 Mesh: m_ObjectHideFlags: 0 @@ -90406,7 +90426,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -90414,15 +90434,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: -13.62 + value: -21.12416 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 25.6 + value: 0.9218712 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -90430,15 +90450,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -90500,13 +90520,18 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &626847832 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 626847829} + m_PrefabAsset: {fileID: 0} --- !u!1001 &628283017 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: -8789529727683405701, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: notificationText @@ -90526,15 +90551,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.x - value: -6.4864435 + value: -13.990603 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.y - value: 10.22 + value: 6.4408503 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.z - value: 35.790524 + value: 11.112394 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.w @@ -90589,6 +90614,11 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} +--- !u!4 &628283018 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} + m_PrefabInstance: {fileID: 628283017} + m_PrefabAsset: {fileID: 0} --- !u!43 &631793619 Mesh: m_ObjectHideFlags: 0 @@ -92503,7 +92533,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -92511,15 +92541,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 17.43 + value: 9.92584 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 12.07 + value: 8.29085 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 39.186 + value: 14.507872 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -92527,15 +92557,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -92597,6 +92627,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &640822036 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 640822033} + m_PrefabAsset: {fileID: 0} --- !u!43 &643120550 Mesh: m_ObjectHideFlags: 0 @@ -93626,7 +93661,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -93634,15 +93669,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 1.5 + value: -6.00416 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: -4.2 + value: -28.878128 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -93650,15 +93685,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -93720,6 +93755,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &665174409 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 665174406} + m_PrefabAsset: {fileID: 0} --- !u!1 &678938548 GameObject: m_ObjectHideFlags: 0 @@ -93812,11 +93852,11 @@ Transform: m_GameObject: {fileID: 678938548} serializedVersion: 2 m_LocalRotation: {x: 0.5, y: -0.5, z: 0.5, w: 0.5} - m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalPosition: {x: -7.50416, y: -0.77915, z: -24.67813} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1625646592} m_LocalEulerAnglesHint: {x: 90, y: -90, z: 0} --- !u!114 &678938551 MonoBehaviour: @@ -107713,7 +107753,7 @@ RectTransform: m_Children: - {fileID: 1007024365} - {fileID: 292895766} - m_Father: {fileID: 0} + m_Father: {fileID: 1625646592} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -107726,7 +107766,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -107734,15 +107774,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 9.7 + value: 2.19584 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 27 + value: 2.3218708 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -107750,15 +107790,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -107820,6 +107860,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &1004365739 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 1004365736} + m_PrefabAsset: {fileID: 0} --- !u!1 &1007024362 GameObject: m_ObjectHideFlags: 0 @@ -134129,12 +134174,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1098531124} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -16.49995, y: 10.56881, z: 19.27294} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -24.00411, y: 6.7896605, z: -5.4051895} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1625646592} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1143870345 GameObject: @@ -134532,12 +134577,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1158761164} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.42363, y: 10.37505, z: 16.23287} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -9.92779, y: 6.5958996, z: -8.445259} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1617980815} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!43 &1167863508 Mesh: @@ -145093,6 +145138,39 @@ Transform: m_Children: [] m_Father: {fileID: 333057066} m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!1 &1617980814 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1617980815} + m_Layer: 0 + m_Name: _MANAGER + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1617980815 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1617980814} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 7.50416, y: 3.77915, z: 24.67813} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1158761166} + - {fileID: 1922855029} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1620426061 GameObject: m_ObjectHideFlags: 0 @@ -145449,13 +145527,61 @@ Transform: m_Children: [] m_Father: {fileID: 333057066} m_LocalEulerAnglesHint: {x: 0, y: -45, z: 90} +--- !u!1 &1625646591 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1625646592} + m_Layer: 0 + m_Name: _SCENE + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1625646592 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1625646591} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 7.50416, y: 3.77915, z: 24.67813} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 678938550} + - {fileID: 333057066} + - {fileID: 1098531126} + - {fileID: 348410792} + - {fileID: 963322862} + - {fileID: 628283018} + - {fileID: 241771775} + - {fileID: 1813306720} + - {fileID: 572767393} + - {fileID: 665174409} + - {fileID: 2145701570} + - {fileID: 1004365739} + - {fileID: 626847832} + - {fileID: 310459322} + - {fileID: 570772204} + - {fileID: 1645920189} + - {fileID: 640822036} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1645920186 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -145463,15 +145589,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: 14.3 + value: 6.7958403 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 35.1 + value: 10.421869 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -145479,15 +145605,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -145549,6 +145675,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &1645920189 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 1645920186} + m_PrefabAsset: {fileID: 0} --- !u!43 &1649158037 Mesh: m_ObjectHideFlags: 0 @@ -146559,7 +146690,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: -8789529727683405701, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: notificationText @@ -146579,15 +146710,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.x - value: 2.08 + value: -5.42416 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.y - value: 3.29 + value: -0.48915005 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalPosition.z - value: 51.64 + value: 26.96187 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.w @@ -146595,7 +146726,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} propertyPath: m_LocalRotation.y @@ -146642,6 +146773,11 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} +--- !u!4 &1813306720 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 600579176653881994, guid: b96d0fcc541b0b947907dd08b9f5beab, type: 3} + m_PrefabInstance: {fileID: 1813306719} + m_PrefabAsset: {fileID: 0} --- !u!43 &1820026756 Mesh: m_ObjectHideFlags: 0 @@ -147317,6 +147453,70 @@ Transform: m_Children: [] m_Father: {fileID: 333057066} m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0} +--- !u!1 &1922855028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1922855029} + - component: {fileID: 1922855030} + m_Layer: 0 + m_Name: NavManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1922855029 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1922855028} + serializedVersion: 2 + 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: 1617980815} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1922855030 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1922855028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.AI.Navigation::Unity.AI.Navigation.NavMeshSurface + m_SerializedVersion: 0 + m_AgentTypeID: 0 + m_CollectObjects: 0 + m_Size: {x: 10, y: 10, z: 10} + m_Center: {x: 0, y: 2, z: 0} + m_LayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_UseGeometry: 0 + m_DefaultArea: 0 + m_GenerateLinks: 0 + m_IgnoreNavMeshAgent: 1 + m_IgnoreNavMeshObstacle: 1 + m_OverrideTileSize: 0 + m_TileSize: 256 + m_OverrideVoxelSize: 0 + m_VoxelSize: 0.16666667 + m_MinRegionArea: 2 + m_NavMeshData: {fileID: 23800000, guid: 84212f9f021e4404f8fe07ca27865272, type: 2} + m_BuildHeightMesh: 0 --- !u!43 &1951987860 Mesh: m_ObjectHideFlags: 0 @@ -150314,7 +150514,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1625646592} m_Modifications: - target: {fileID: 5687887011233860168, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_Layer @@ -150322,15 +150522,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.x - value: -8.8 + value: -16.304161 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.y - value: 1.08 + value: -2.69915 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalPosition.z - value: 8.1 + value: -16.578129 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.w @@ -150338,15 +150538,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -150408,25 +150608,14 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 112 m_CollisionDetection: 0 +--- !u!4 &2145701570 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6442306242859885696, guid: 15df559ce497e104a81254e0adf3107e, type: 3} + m_PrefabInstance: {fileID: 2145701567} + m_PrefabAsset: {fileID: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 678938550} - - {fileID: 333057066} - - {fileID: 1098531126} - - {fileID: 348410792} - - {fileID: 963322862} - - {fileID: 628283017} - - {fileID: 241771774} - - {fileID: 1813306719} - - {fileID: 572767392} - - {fileID: 665174406} - - {fileID: 2145701567} - - {fileID: 1004365736} - - {fileID: 626847829} - - {fileID: 310459319} - - {fileID: 570772201} - - {fileID: 1645920186} - - {fileID: 640822033} - - {fileID: 1158761166} + - {fileID: 1625646592} + - {fileID: 1617980815} diff --git a/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset b/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset new file mode 100644 index 00000000..9bbb6b32 Binary files /dev/null and b/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset differ diff --git a/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset.meta b/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset.meta new file mode 100644 index 00000000..1d193e6f --- /dev/null +++ b/Assets/Scenes/Cho môn AI/Only AI/NavMesh-NavManager 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84212f9f021e4404f8fe07ca27865272 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 23800000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI NPC/EnemyAI.cs b/Assets/Scripts/AI NPC/EnemyAI.cs index 9f94de9b..d7190db5 100644 --- a/Assets/Scripts/AI NPC/EnemyAI.cs +++ b/Assets/Scripts/AI NPC/EnemyAI.cs @@ -1,24 +1,31 @@ +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; -using UnityEngine.AI; // Cần thiết để dùng NavMesh -using Hallucinate.Audio; +using UnityEngine.AI; -[RequireComponent(typeof(NavMeshAgent))] // Tự động thêm component này nếu chưa có +[RequireComponent(typeof(NavMeshAgent))] +[RequireComponent(typeof(Rigidbody))] public class EnemyAI : MonoBehaviour { [Header("References")] public Transform player; - [Header("Detection")] - public float detectRange = 10f; - public float moveSpeed = 3f; - public float rotateSpeed = 50f; + [Header("Field of View")] + [Range(0, 360)] public float viewAngle = 90f; + public float viewRadius = 20f; + public LayerMask targetLayerMask; // Gán layer của Player + public LayerMask obstacleLayerMask; // Gán layer của Tường, chướng ngại vật + + private bool canSeePlayer = false; + private Vector3 lastKnownPlayerPosition; + private bool isInvestigating = false; [Header("Patrol Area")] - public float patrolRadius = 15f; // Bán kính khu vực tuần tra - public float patrolWaitTime = 2f; // Thời gian đứng chờ trước khi đi điểm khác - private Vector3 startPosition; - private float currentWaitTime; + public Transform[] patrolPoints; + private int currentPatrolIndex = 0; + public float moveSpeed = 3f; + public float chaseSpeed = 5f; [Header("Artifact")] public bool playerHasArtifact; @@ -28,74 +35,127 @@ public class EnemyAI : MonoBehaviour public Transform firePoint; public float minShootDelay = 1f; public float maxShootDelay = 3f; + public float rotateSpeed = 50f; - [Header("Audio")] - public string alertSound = "Enemy_Alert"; - public string shootSound = "Enemy_Shoot"; - private bool hasSpottedPlayer; // Để chỉ kêu alert 1 lần - + [Header("Dodge Mechanics")] + public float dodgeForce = 8f; // Lực đẩy văng đi + public float dodgeDuration = 0.5f; // Thời gian nhào lộn/né + public float dodgeCooldown = 3f; // Thời gian chờ giữa 2 lần né + + private float nextDodgeTime; + private bool isDodging = false; + private Rigidbody rb; + private float nextShootTime; private NavMeshAgent agent; - public Node behaviorTreeRoot; private void Start() { agent = GetComponent(); - agent.speed = moveSpeed; - - // Lưu lại vị trí ban đầu để làm tâm của khu vực tuần tra - startPosition = transform.position; + rb = GetComponent(); + // Tự động tìm các điểm tuần tra nếu chưa gán + if (patrolPoints == null || patrolPoints.Length == 0) + { + patrolPoints = GameObject.FindGameObjectsWithTag("PatrolPoint") + .Select(go => go.transform).ToArray(); + } nextShootTime = Time.time + Random.Range(minShootDelay, maxShootDelay); + InitBehaviorTree(); - FindPlayer(); + StartCoroutine(FindTargetWithDelay(0.1f)); // Chạy FOV quét mục tiêu } private void Update() { - // Nếu mất reference (Player chết hoặc chưa spawn), liên tục tìm lại - if (player == null) + if (player == null) FindPlayer(); + if (Input.GetMouseButtonDown(0) && canSeePlayer && !isDodging && Time.time >= nextDodgeTime) { - FindPlayer(); + StartCoroutine(DodgeRoutine()); } - - // Chỉ chạy AI nếu đã tìm thấy player (hoặc bạn có thể cho tuần tra ngay cả khi chưa có player tùy logic game) + if (isDodging) return; behaviorTreeRoot?.Evaluate(); } private void FindPlayer() { GameObject playerObj = GameObject.FindGameObjectWithTag("Player"); - if (playerObj != null) + if (playerObj != null) player = playerObj.transform; + } + + // Coroutine tối ưu việc quét mục tiêu + private IEnumerator FindTargetWithDelay(float delay) + { + while (true) { - player = playerObj.transform; + yield return new WaitForSeconds(delay); + FindVisibleTargets(); + } + } + + private void FindVisibleTargets() + { + canSeePlayer = false; + Collider[] colliders = Physics.OverlapSphere(transform.position, viewRadius, targetLayerMask); + + foreach (var col in colliders) + { + Transform target = col.transform; + Vector3 direction = (target.position - transform.position).normalized; + + float angle = Vector3.Angle(transform.forward, direction); + + // Nếu nằm trong góc nhìn + if (angle < viewAngle / 2) + { + float distanceToTarget = Vector3.Distance(transform.position, target.position); + + // Nếu không có vật cản che khuất + if (!Physics.Raycast(transform.position, direction, distanceToTarget, obstacleLayerMask)) + { + canSeePlayer = true; + isInvestigating = true; + lastKnownPlayerPosition = target.position; + + Debug.DrawLine(transform.position, target.position, Color.blue, 0.1f); + break; // Thấy player rồi thì dừng vòng lặp + } + } } } private void InitBehaviorTree() { - // Player có artifact -> focus + shoot + // 1. Cầm Artifact -> Đứng bắn var laserSequence = new Sequence(new List { new TaskNode(CheckHasArtifact), new TaskNode(ActionFocusAndShoot) }); - // Thấy player -> chạy tới + // 2. Thấy Player -> Đuổi theo var chaseSequence = new Sequence(new List { new TaskNode(CheckCanSeePlayer), new TaskNode(ActionMoveToPlayer) }); - // Không thấy ai -> Tuần tra bằng NavMesh + // 3. Mất dấu Player -> Đi tới vị trí cuối cùng để điều tra + var investigateSequence = new Sequence(new List + { + new TaskNode(CheckShouldInvestigate), + new TaskNode(ActionInvestigate) + }); + + // 4. Không có gì -> Tuần tra theo điểm var patrolNode = new TaskNode(ActionPatrol); behaviorTreeRoot = new Selector(new List { laserSequence, chaseSequence, + investigateSequence, patrolNode }); } @@ -109,22 +169,12 @@ public class EnemyAI : MonoBehaviour private NodeState CheckCanSeePlayer() { - if (player == null) return NodeState.Failure; + return canSeePlayer ? NodeState.Success : NodeState.Failure; + } - float distance = Vector3.Distance(transform.position, player.position); - - if (distance <= detectRange) - { - if (!hasSpottedPlayer) - { - hasSpottedPlayer = true; - AudioManager.Instance?.Play(alertSound, position: transform.position); - } - return NodeState.Success; - } - - hasSpottedPlayer = false; // Reset nếu player ra khỏi tầm mắt - return NodeState.Failure; + private NodeState CheckShouldInvestigate() + { + return isInvestigating ? NodeState.Success : NodeState.Failure; } #endregion @@ -133,32 +183,19 @@ public class EnemyAI : MonoBehaviour private NodeState ActionPatrol() { - // Debug.Log("Patrolling..."); - if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure; + if (patrolPoints.Length == 0) return NodeState.Failure; - agent.isStopped = false; // Đảm bảo NPC được phép di chuyển - agent.speed = moveSpeed * 0.5f; // Đi dạo nên đi chậm lại một chút + Debug.Log("Patrolling..."); + agent.isStopped = false; + agent.speed = moveSpeed; - // Kiểm tra xem NPC đã đến điểm đích chưa - if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance) + // Đi tới điểm tuần tra hiện tại + agent.SetDestination(patrolPoints[currentPatrolIndex].position); + + // Nếu đã tới nơi, chuyển sang điểm tiếp theo + if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending) { - currentWaitTime += Time.deltaTime; - - // Chờ một lúc rồi mới chọn điểm mới - if (currentWaitTime >= patrolWaitTime) - { - // Tìm một điểm ngẫu nhiên trong bán kính cho trước - Vector3 randomDirection = Random.insideUnitSphere * patrolRadius; - randomDirection += startPosition; - NavMeshHit hit; - - // Đảm bảo điểm ngẫu nhiên nằm trên bề mặt NavMesh hợp lệ - if (NavMesh.SamplePosition(randomDirection, out hit, patrolRadius, 1)) - { - agent.SetDestination(hit.position); - } - currentWaitTime = 0f; - } + currentPatrolIndex = (currentPatrolIndex + 1) % patrolPoints.Length; } return NodeState.Running; @@ -168,39 +205,48 @@ public class EnemyAI : MonoBehaviour { if (player == null) return NodeState.Failure; - // Debug.Log("Chasing Player"); - - if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure; - + Debug.Log("Chasing Player..."); agent.isStopped = false; - agent.speed = moveSpeed; // Phục hồi tốc độ rượt đuổi + agent.speed = chaseSpeed; agent.SetDestination(player.position); return NodeState.Running; } + private NodeState ActionInvestigate() + { + Debug.Log("Investigating last known position..."); + agent.isStopped = false; + agent.speed = moveSpeed; + + agent.SetDestination(lastKnownPlayerPosition); + + // Nếu đi tới nơi mà vẫn không thấy player -> Hủy điều tra, quay về tuần tra + if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending) + { + isInvestigating = false; + return NodeState.Success; + } + + return NodeState.Running; + } + private NodeState ActionFocusAndShoot() { if (player == null) return NodeState.Failure; - // Debug.Log("Focus and Shoot!"); + agent.isStopped = true; // Đứng lại để bắn - if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure; - - // Dừng NavMeshAgent lại để đứng bắn, tránh bị trượt - agent.isStopped = true; - - // Focus player + // Xoay người về phía player Vector3 dir = player.position - transform.position; dir.y = 0f; - if (dir != Vector3.zero) { Quaternion targetRotation = Quaternion.LookRotation(dir); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotateSpeed * Time.deltaTime); } - // Shoot with random delay + // Bắn if (Time.time >= nextShootTime) { ShootLaser(); @@ -214,9 +260,67 @@ public class EnemyAI : MonoBehaviour { if (laserPrefab == null || firePoint == null) return; Instantiate(laserPrefab, firePoint.position, firePoint.rotation); - AudioManager.Instance?.Play(shootSound, position: transform.position); - // Debug.Log("Laser Shot!"); + Debug.Log("Laser Shot!"); } #endregion + #region DODGE MECHANIC + + private IEnumerator DodgeRoutine() + { + Debug.Log("Dodging!"); + isDodging = true; + nextDodgeTime = Time.time + dodgeCooldown; + + // 1. Tắt AI tìm đường để Vật lý tiếp quản + agent.enabled = false; + rb.isKinematic = false; // Đảm bảo Rigidbody có thể nhận lực + + // 2. Tính toán hướng né: Random nhảy sang Trái hoặc Phải + int randomDirection = Random.Range(0, 2) == 0 ? -1 : 1; + + // Lấy vector hướng ngang của NPC nhân với trái (-1) hoặc phải (1) + Vector3 dodgeDir = transform.right * randomDirection; + + // Có thể cộng thêm một chút lực nhảy lên (trục Y) nếu muốn NPC hơi nảy lên + // dodgeDir.y = 0.5f; + + // 3. Tác dụng lực đẩy tức thời (Impulse) + rb.AddForce(dodgeDir * dodgeForce, ForceMode.Impulse); + + // 4. Chờ NPC văng đi trong thời gian chỉ định + yield return new WaitForSeconds(dodgeDuration); + + // 5. Thắng gấp (Dừng toàn bộ gia tốc vật lý lại) + // Lưu ý: Unity 6 dùng linearVelocity thay vì velocity như các bản cũ + rb.linearVelocity = Vector3.zero; + rb.angularVelocity = Vector3.zero; + + // 6. Bật lại AI tìm đường + rb.isKinematic = true; // Trả lại Rigidbody về trạng thái không ảnh hưởng vật lý + agent.enabled = true; + + isDodging = false; + } + + #endregion + // Vẽ FOV trên Scene để dễ debug + private void OnDrawGizmosSelected() + { + Gizmos.color = Color.white; + Gizmos.DrawWireSphere(transform.position, viewRadius); + + Vector3 viewAngleA = DirFromAngle(-viewAngle / 2); + Vector3 viewAngleB = DirFromAngle(viewAngle / 2); + + Gizmos.color = Color.yellow; + Gizmos.DrawLine(transform.position, transform.position + viewAngleA * viewRadius); + Gizmos.DrawLine(transform.position, transform.position + viewAngleB * viewRadius); + } + + private Vector3 DirFromAngle(float angleInDegrees) + { + angleInDegrees += transform.eulerAngles.y; + return new Vector3(Mathf.Sin(angleInDegrees * Mathf.Deg2Rad), 0, Mathf.Cos(angleInDegrees * Mathf.Deg2Rad)); + } } \ No newline at end of file