Skip to content

Commit 81808be

Browse files
committed
Fix monster attack animation not triggering
1 parent 20722fb commit 81808be

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Assets/Scripts/AI/AiActors/AiMonster.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ private void OnTriggerExit(Collider c)
6767
InteractWith(c.GetComponent<IInteractable>(), InteractionType.INTERACTION_TRIGGER_EXIT);
6868
}
6969

70-
private void LateUpdate()
71-
{
72-
m_AttackThisFrame = "";
73-
}
74-
7570
private void InteractWith(IInteractable interactable, InteractionType interactionType)
7671
{
7772
if (interactable != null) // null check done here instead.
@@ -89,8 +84,8 @@ public void Attack(float attackInterval)
8984
if (m_CanAttack)
9085
{
9186
float attack = m_MonsterAnimation.RandomizeAttack(out m_AttackThisFrame)/2;
87+
Debug.Log("Aimonster " + m_AttackThisFrame);
9288
//logic for damaging the player here
93-
9489
StartCoroutine(DealDamage(attack));
9590
StartCoroutine(SetCanAttack(attack + attackInterval));
9691
m_CanAttack = false;
@@ -108,6 +103,11 @@ public string GetAttack()
108103
return m_AttackThisFrame;
109104
}
110105

106+
public void ResetAttackThisFrame()
107+
{
108+
m_AttackThisFrame = "";
109+
}
110+
111111
public AiAnimation GetMonsterAnimation()
112112
{
113113
return m_MonsterAnimation;

Assets/Scripts/Network/MonsterNetworkHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ private void Update()
5050

5151
string attackName = m_aiMonster.GetAttack();
5252
if (attackName.Length > 0)
53+
{
5354
networkObject.SendRpc(RPC_TRIGGER_ATTACK_ANIM, Receivers.Others, attackName);
55+
Debug.Log("Monster attacked");
56+
m_aiMonster.ResetAttackThisFrame();
57+
}
5458
}
5559
else
5660
{
@@ -63,6 +67,7 @@ private void Update()
6367

6468
public override void TriggerAttackAnim(RpcArgs args)
6569
{
70+
Debug.Log("Monster is attacking");
6671
m_aiMonster.GetMonsterAnimation()?.SetAttackTrigger(args.GetNext<string>());
6772
}
6873
}

Assets/Scripts/UI/UIDisplayOnHover.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class UIDisplayOnHover : MonoBehaviour
1414
public void OnHover()
1515
{
1616
m_HoveredTime = Time.time;
17-
Debug.Log("Hovered!");
1817
}
1918

2019
public void Update()

0 commit comments

Comments
 (0)