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 EnemyRange : MonoBehaviour {
- public float speed;
- public Transform player;
- private Animator animator;
- void Start()
- {
- }
- void FixedUpdate()
- {
- }
- private void OnTriggerStay(Collider other)
- {
- if (other.tag == "MainCharacter")
- {
- transform.position = Vector3.MoveTowards(transform.position,
- player.position, speed
- * Time.deltaTime);
- }
- else
- {
- animator.SetBool("isIdle", true);
- }
- }
- public float speed;
- public float range;
- public Transform player;
- void Start()
- {
- }
- void FixedUpdate()
- {
- if (Vector3.Distance(player.position, transform.position) <= range)
- Debug.Log("In Range" + other.name);
- {
- transform.position = Vector2.MoveTowards(transform.position,
- player.position, speed *
- Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement