dronkowitz

BasicAI.cs

Mar 31st, 2021 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.AI;
  5.  
  6. public class BasicAI : MonoBehaviour
  7. {
  8.     public Transform targetposition;
  9.     public NavMeshAgent agent;
  10.     public enum STATE
  11.     {
  12.         Idle,
  13.         Move,
  14.         Special,
  15.         Attack,
  16.         Dead,
  17.         Inair
  18.     }
  19.  
  20.     public STATE curState = STATE.Move;
  21.     // Start is called before the first frame update
  22.     void Start()
  23.     {
  24.        
  25.     }
  26.  
  27.     // Update is called once per frame
  28.     void Update()
  29.     {
  30.         switch (curState)
  31.         {
  32.             case STATE.Idle:
  33.                 IdleState();
  34.                 break;
  35.             case STATE.Move:
  36.                 MoveState();
  37.                 break;
  38.             case STATE.Special:
  39.                 SpecialState();
  40.                 break;
  41.             case STATE.Attack:
  42.                 AttackState();
  43.                 break;
  44.             case STATE.Inair:
  45.                 InairState();
  46.                 break;
  47.             case STATE.Dead:
  48.                 DeadState();
  49.                     break;
  50.  
  51.  
  52.         }
  53.     }
  54.  
  55.     public void SetState(STATE newState)
  56.     {
  57.         curState = newState;
  58.     }
  59.  
  60.     #region states
  61.     public void IdleState()
  62.     {
  63.        
  64.     }
  65.  
  66.     public void MoveState()
  67.     {
  68.         agent.SetDestination(targetposition.position);
  69.  
  70.     }
  71.     public void SpecialState()
  72.     {
  73.  
  74.     }
  75.     public void AttackState()
  76.     {
  77.  
  78.     }
  79.     public void InairState()
  80.     {
  81.  
  82.     }
  83.     public void DeadState()
  84.     {
  85.  
  86.     }
  87.  
  88.    
  89.  
  90.    
  91.     #endregion
  92. }
  93.  
Add Comment
Please, Sign In to add comment