Skip to content

Commit

Permalink
Hotfix for Issue UnityTechnologies#383 - Slime Critter Pushing Player…
Browse files Browse the repository at this point in the history
… Excessively
  • Loading branch information
asb9599 committed Apr 7, 2021
1 parent 4f5a162 commit f15cedc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_attackConfigSO: {fileID: 11400000, guid: fa67200955f70e64abecdd0107951472, type: 2}
onHit:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2038924309811281612}
m_TargetAssemblyTypeName: SlimeCritterAttackController, Assembly-CSharp
m_MethodName: StopAttack
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!135 &6188918218575104391
SphereCollider:
m_ObjectHideFlags: 0
Expand Down
7 changes: 7 additions & 0 deletions UOP1_Project/Assets/Scripts/Characters/Attack.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class Attack : MonoBehaviour
{
[SerializeField] private AttackConfigSO _attackConfigSO;
[SerializeField] [Tooltip("Any additional events to be called upon a successful hit")]
private UnityEvent onHit;

public AttackConfigSO AttackConfig => _attackConfigSO;

Expand All @@ -21,7 +24,11 @@ private void OnTriggerEnter(Collider other)
if (other.TryGetComponent(out Damageable damageableComp))
{
if (!damageableComp.GetHit)
{
damageableComp.ReceiveAnAttack(_attackConfigSO.AttackStrength);
// Invoke any necessary hit events
onHit?.Invoke();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ void Update()
_innerTime -= Time.deltaTime;
}
}

public void StopAttack()
{
// Reset innerTime
_innerTime = 0.0f;
}
}

0 comments on commit f15cedc

Please sign in to comment.