From 8e9968c58f2fb9e3b1e05812dc31e2eed624ba6f Mon Sep 17 00:00:00 2001 From: Yohann Puyhaubert Date: Tue, 9 Mar 2021 14:07:42 +0100 Subject: [PATCH 1/3] Update combat SM --- .../Protagonist/Conditions/Timer_AttackAnimation.asset | 3 +-- .../StateMachine/Protagonist/PigChef_TransitionTable.asset | 6 ------ .../StateMachine/Protagonist/States/Attack.asset | 1 + 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset index 13f14f551..6e208de38 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset @@ -12,5 +12,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8139f9f328ed1144690b7a9ffca2d5b4, type: 3} m_Name: Timer_AttackAnimation m_EditorClassIdentifier: - cacheResult: 1 - timerLength: 0.5 + timerLength: 0.75 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset index b2c278ae3..bae57d83e 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset @@ -175,9 +175,6 @@ MonoBehaviour: - ExpectedResult: 0 Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2} Operator: 0 - - ExpectedResult: 1 - Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2} - Operator: 0 - FromState: {fileID: 11400000, guid: bda8bfafdf35e3e4092bb96279d4894c, type: 2} ToState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2} Conditions: @@ -187,9 +184,6 @@ MonoBehaviour: - ExpectedResult: 1 Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2} Operator: 0 - - ExpectedResult: 1 - Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2} - Operator: 0 - FromState: {fileID: 11400000, guid: 027d32476800b3543b2f5446a59054c8, type: 2} ToState: {fileID: 11400000, guid: 78675b2bf031c3f4a9c28dda969298e2, type: 2} Conditions: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Attack.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Attack.asset index 47e410c83..e80717882 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Attack.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Attack.asset @@ -14,3 +14,4 @@ MonoBehaviour: m_EditorClassIdentifier: _actions: - {fileID: 11400000, guid: 5cb6e4529b034ff4dbc7a7aa863ce969, type: 2} + - {fileID: 11400000, guid: 23e8862a3aca1b6439bda3bf27d03897, type: 2} From d4fb7fd1a085285cb78f18d68b19656221a1fbdc Mon Sep 17 00:00:00 2001 From: Yohann Puyhaubert Date: Tue, 9 Mar 2021 16:00:28 +0100 Subject: [PATCH 2/3] Fix attack logic to consume attack from animation events --- .../Art/Characters/PigChef/Animation/CaneHit.anim | 7 +++++++ .../Characters/PigChef/Animation/CaneHit2.anim | 7 +++++++ UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta | 8 -------- .../Conditions/Timer_AttackAnimation.asset | 15 --------------- .../Conditions/Timer_AttackAnimation.asset.meta | 8 -------- .../Protagonist/PigChef_TransitionTable.asset | 8 ++++---- .../Assets/Scripts/Characters/Protagonist.cs | 8 ++++---- .../Actions/ClearInputCache_OnEnterSO.cs | 1 - 8 files changed, 22 insertions(+), 40 deletions(-) delete mode 100644 UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta delete mode 100644 UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset delete mode 100644 UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset.meta diff --git a/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit.anim b/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit.anim index b0cbf48be..751f72c2e 100644 --- a/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit.anim +++ b/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit.anim @@ -75675,6 +75675,13 @@ AnimationClip: m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 m_Events: + - time: 0.68333334 + functionName: ConsumeAttackInput + data: + objectReferenceParameter: {fileID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 - time: 0.73333335 functionName: PlaySlashEffect data: diff --git a/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit2.anim b/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit2.anim index d9f361f37..5097ed110 100644 --- a/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit2.anim +++ b/UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit2.anim @@ -80121,6 +80121,13 @@ AnimationClip: m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 m_Events: + - time: 0.78333336 + functionName: ConsumeAttackInput + data: + objectReferenceParameter: {fileID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 - time: 0.8666667 functionName: PlayReverseSlashEffect data: diff --git a/UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta b/UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta deleted file mode 100644 index 40a77073e..000000000 --- a/UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6a7ead41d5a038a42b2d15a980df4e00 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset deleted file mode 100644 index 6e208de38..000000000 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset +++ /dev/null @@ -1,15 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8139f9f328ed1144690b7a9ffca2d5b4, type: 3} - m_Name: Timer_AttackAnimation - m_EditorClassIdentifier: - timerLength: 0.75 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset.meta deleted file mode 100644 index 1cb54ada8..000000000 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 373ff606aeb23834eb964bdf9a6f6e3c -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset index bae57d83e..afa9983eb 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset @@ -169,8 +169,8 @@ MonoBehaviour: - FromState: {fileID: 11400000, guid: bda8bfafdf35e3e4092bb96279d4894c, type: 2} ToState: {fileID: 11400000, guid: 027d32476800b3543b2f5446a59054c8, type: 2} Conditions: - - ExpectedResult: 0 - Condition: {fileID: 11400000, guid: 373ff606aeb23834eb964bdf9a6f6e3c, type: 2} + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2} Operator: 0 - ExpectedResult: 0 Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2} @@ -178,8 +178,8 @@ MonoBehaviour: - FromState: {fileID: 11400000, guid: bda8bfafdf35e3e4092bb96279d4894c, type: 2} ToState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2} Conditions: - - ExpectedResult: 0 - Condition: {fileID: 11400000, guid: 373ff606aeb23834eb964bdf9a6f6e3c, type: 2} + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2} Operator: 0 - ExpectedResult: 1 Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2} diff --git a/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs b/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs index 4b668700b..e8fca5099 100644 --- a/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs +++ b/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs @@ -16,7 +16,7 @@ public class Protagonist : MonoBehaviour //These fields are read and manipulated by the StateMachine actions [NonSerialized] public bool jumpInput; [NonSerialized] public bool extraActionInput; - [NonSerialized] public bool attackInput; + public bool attackInput; [NonSerialized] public Vector3 movementInput; //Initial input coming from the Protagonist script [NonSerialized] public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions [NonSerialized] public ControllerColliderHit lastHit; @@ -44,7 +44,6 @@ private void OnEnable() _inputReader.startedRunning += OnStartedRunning; _inputReader.stoppedRunning += OnStoppedRunning; _inputReader.attackEvent += OnStartedAttack; - _inputReader.attackCanceledEvent += OnStoppedAttack; //... } @@ -58,7 +57,6 @@ private void OnDisable() _inputReader.startedRunning -= OnStartedRunning; _inputReader.stoppedRunning -= OnStoppedRunning; _inputReader.attackEvent -= OnStartedAttack; - _inputReader.attackCanceledEvent -= OnStoppedAttack; //... } @@ -123,5 +121,7 @@ private void OnOpenInventory() } private void OnStartedAttack() => attackInput = true; - private void OnStoppedAttack() => attackInput = false; + + // Triggered from Animation Event + public void ConsumeAttackInput() => attackInput = false; } diff --git a/UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ClearInputCache_OnEnterSO.cs b/UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ClearInputCache_OnEnterSO.cs index cb7cb814b..57997e754 100644 --- a/UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ClearInputCache_OnEnterSO.cs +++ b/UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ClearInputCache_OnEnterSO.cs @@ -26,7 +26,6 @@ public override void OnUpdate() public override void OnStateEnter() { _protagonist.jumpInput = false; - _protagonist.attackInput = false; _interactionManager.currentInteractionType = InteractionType.None; } } From 6269909111ae610535ee1e255c3a0dd65f1bee27 Mon Sep 17 00:00:00 2001 From: Yohann Puyhaubert <42570903+treivize@users.noreply.github.com> Date: Mon, 15 Mar 2021 12:38:08 +0100 Subject: [PATCH 3/3] Hide back the attack input Sorry, it was displayed on inspector for debug purpose only --- UOP1_Project/Assets/Scripts/Characters/Protagonist.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs b/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs index e8fca5099..93e4d0f5c 100644 --- a/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs +++ b/UOP1_Project/Assets/Scripts/Characters/Protagonist.cs @@ -16,7 +16,7 @@ public class Protagonist : MonoBehaviour //These fields are read and manipulated by the StateMachine actions [NonSerialized] public bool jumpInput; [NonSerialized] public bool extraActionInput; - public bool attackInput; + [NonSerialized] public bool attackInput; [NonSerialized] public Vector3 movementInput; //Initial input coming from the Protagonist script [NonSerialized] public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions [NonSerialized] public ControllerColliderHit lastHit;