]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Enemies/Boss/BossMovement.cs
Idle Animation Schnecke
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Enemies / Boss / BossMovement.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class BossMovement : StateMachineBehaviour
6 {   
7     FollowPlayer fp;
8
9     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
10     override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
11     {
12         fp = animator.GetComponent<FollowPlayer>();
13     }
14
15     // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
16     override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
17     {
18         if (fp.distToPlayer < fp.agroRange - 20)
19         {
20             animator.SetBool("Idle", false);
21             animator.SetTrigger("Attack");
22         }
23         else if (fp.distToPlayer > fp.agroRange)
24         {
25             animator.SetBool("Idle", true);
26         }
27     }
28
29     // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
30     override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
31     {
32         animator.ResetTrigger("Attack");
33         animator.SetBool("Idle", false);
34     }
35 }