Advertisement
GoodNoodle

EnemyController

Sep 23rd, 2021
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public enum EnemyStates
  7. {
  8.     idle,
  9.     walk,
  10.     attack,
  11.     stagger,
  12.     grab
  13. }
  14. public class EnemyController : MonoBehaviour
  15. {
  16.    
  17.     public EnemyStates currentState;
  18.     public int baseAttack;
  19.     public string Name;
  20.     public float moveSpeed;
  21.    
  22.    
  23.  
  24.     private void Awake()
  25.     {
  26.      
  27.        
  28.     }
  29.     public void Knock(Rigidbody2D theRB, float knockTime)
  30.     {
  31.         StartCoroutine(Knockco(theRB, knockTime));
  32.        
  33.     }
  34.     private IEnumerator Knockco(Rigidbody2D theRB, float knockTime)
  35.     {
  36.         if (theRB != null)
  37.         {
  38.  
  39.             yield return new WaitForSeconds(knockTime);
  40.             theRB.velocity = Vector2.zero;
  41.             theRB.GetComponent<EnemyController>().currentState = EnemyStates.idle;
  42.             theRB.velocity = Vector2.zero;
  43.         }
  44.     }
  45.  
  46. }
  47.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement