Skip to content

Commit d4fb7fd

Browse files
committed
Fix attack logic to consume attack from animation events
1 parent 8e9968c commit d4fb7fd

File tree

8 files changed

+22
-40
lines changed

8 files changed

+22
-40
lines changed

UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit.anim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75675,6 +75675,13 @@ AnimationClip:
7567575675
m_HasGenericRootTransform: 0
7567675676
m_HasMotionFloatCurves: 0
7567775677
m_Events:
75678+
- time: 0.68333334
75679+
functionName: ConsumeAttackInput
75680+
data:
75681+
objectReferenceParameter: {fileID: 0}
75682+
floatParameter: 0
75683+
intParameter: 0
75684+
messageOptions: 0
7567875685
- time: 0.73333335
7567975686
functionName: PlaySlashEffect
7568075687
data:

UOP1_Project/Assets/Art/Characters/PigChef/Animation/CaneHit2.anim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80121,6 +80121,13 @@ AnimationClip:
8012180121
m_HasGenericRootTransform: 0
8012280122
m_HasMotionFloatCurves: 0
8012380123
m_Events:
80124+
- time: 0.78333336
80125+
functionName: ConsumeAttackInput
80126+
data:
80127+
objectReferenceParameter: {fileID: 0}
80128+
floatParameter: 0
80129+
intParameter: 0
80130+
messageOptions: 0
8012480131
- time: 0.8666667
8012580132
functionName: PlayReverseSlashEffect
8012680133
data:

UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset

Lines changed: 0 additions & 15 deletions
This file was deleted.

UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_AttackAnimation.asset.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ MonoBehaviour:
169169
- FromState: {fileID: 11400000, guid: bda8bfafdf35e3e4092bb96279d4894c, type: 2}
170170
ToState: {fileID: 11400000, guid: 027d32476800b3543b2f5446a59054c8, type: 2}
171171
Conditions:
172-
- ExpectedResult: 0
173-
Condition: {fileID: 11400000, guid: 373ff606aeb23834eb964bdf9a6f6e3c, type: 2}
172+
- ExpectedResult: 1
173+
Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2}
174174
Operator: 0
175175
- ExpectedResult: 0
176176
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}
177177
Operator: 0
178178
- FromState: {fileID: 11400000, guid: bda8bfafdf35e3e4092bb96279d4894c, type: 2}
179179
ToState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
180180
Conditions:
181-
- ExpectedResult: 0
182-
Condition: {fileID: 11400000, guid: 373ff606aeb23834eb964bdf9a6f6e3c, type: 2}
181+
- ExpectedResult: 1
182+
Condition: {fileID: 11400000, guid: ac445a33a0d072a4b96458c8ea343d49, type: 2}
183183
Operator: 0
184184
- ExpectedResult: 1
185185
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}

UOP1_Project/Assets/Scripts/Characters/Protagonist.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Protagonist : MonoBehaviour
1616
//These fields are read and manipulated by the StateMachine actions
1717
[NonSerialized] public bool jumpInput;
1818
[NonSerialized] public bool extraActionInput;
19-
[NonSerialized] public bool attackInput;
19+
public bool attackInput;
2020
[NonSerialized] public Vector3 movementInput; //Initial input coming from the Protagonist script
2121
[NonSerialized] public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions
2222
[NonSerialized] public ControllerColliderHit lastHit;
@@ -44,7 +44,6 @@ private void OnEnable()
4444
_inputReader.startedRunning += OnStartedRunning;
4545
_inputReader.stoppedRunning += OnStoppedRunning;
4646
_inputReader.attackEvent += OnStartedAttack;
47-
_inputReader.attackCanceledEvent += OnStoppedAttack;
4847
//...
4948
}
5049

@@ -58,7 +57,6 @@ private void OnDisable()
5857
_inputReader.startedRunning -= OnStartedRunning;
5958
_inputReader.stoppedRunning -= OnStoppedRunning;
6059
_inputReader.attackEvent -= OnStartedAttack;
61-
_inputReader.attackCanceledEvent -= OnStoppedAttack;
6260
//...
6361
}
6462

@@ -123,5 +121,7 @@ private void OnOpenInventory()
123121
}
124122

125123
private void OnStartedAttack() => attackInput = true;
126-
private void OnStoppedAttack() => attackInput = false;
124+
125+
// Triggered from Animation Event
126+
public void ConsumeAttackInput() => attackInput = false;
127127
}

UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ClearInputCache_OnEnterSO.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public override void OnUpdate()
2626
public override void OnStateEnter()
2727
{
2828
_protagonist.jumpInput = false;
29-
_protagonist.attackInput = false;
3029
_interactionManager.currentInteractionType = InteractionType.None;
3130
}
3231
}

0 commit comments

Comments
 (0)