Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MoleAI : MonoBehaviour
- {
- public float MoveSpeed;
- public Transform player;
- public Transform AgroRange;
- public Transform AttackRange;
- private Animator anim;
- private void Start()
- {
- anim = GetComponent<Animator>();
- }
- void Update()
- {
- {
- if (player.position.x >= AttackRange.position.x)
- {
- anim.SetBool("BossAttacking", true);
- }
- if (player.position.x >= AgroRange.position.x)
- {
- anim.SetBool("BossRunning", true);
- }
- if (player.position.x > transform.position.x)
- {
- transform.Translate(Vector2.right * Time.deltaTime * MoveSpeed);
- transform.localScale = new Vector2(-20f, 20f);
- }
- else if (player.position.x < transform.position.x)
- {
- transform.Translate(Vector2.left * Time.deltaTime * MoveSpeed);
- transform.localScale = new Vector2(20f, 20f);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement