]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Gegner/Boss/BossMovement.cs
Text-Box v0.1
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Gegner / 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.SetTrigger("Attack");
21         }
22     }
23
24     // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
25     override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
26     {
27         animator.ResetTrigger("Attack");
28     }
29 }