Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MoleAI : MonoBehaviour
  6. {
  7.  
  8.     public float MoveSpeed;
  9.     public Transform player;
  10.     public Transform AgroRange;
  11.     public Transform AttackRange;
  12.     private Animator anim;
  13.  
  14.     private void Start()
  15.     {
  16.         anim = GetComponent<Animator>();
  17.     }
  18.  
  19.     void Update()
  20.     {
  21.  
  22.         {
  23.             if (player.position.x >= AttackRange.position.x)
  24.             {
  25.                 anim.SetBool("BossAttacking", true);
  26.             }
  27.  
  28.             if (player.position.x >= AgroRange.position.x)
  29.             {
  30.                 anim.SetBool("BossRunning", true);
  31.             }
  32.  
  33.             if (player.position.x > transform.position.x)
  34.             {
  35.                 transform.Translate(Vector2.right * Time.deltaTime * MoveSpeed);
  36.                 transform.localScale = new Vector2(-20f, 20f);
  37.             }
  38.             else if (player.position.x < transform.position.x)
  39.  
  40.             {
  41.                 transform.Translate(Vector2.left * Time.deltaTime * MoveSpeed);
  42.                 transform.localScale = new Vector2(20f, 20f);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement