Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for Issue #383 - Slime Critter Pushing Player Excessively #404

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}