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 PlayerCheck : MonoBehaviour
- {
- /// <summary>
- /// MAKE SURE THE COLLIDER ATTACHED TO THIS SCRIPT IS A TRIGGER AND 2D
- /// ALSO MAKE SURE THE PLAYER IS TAGGED AS PLAYER
- /// ALSO MAKE SURE THE FILE NAME IN THE PROJECT IS THE SAME AS THE CLASS NAME P.S. That's "PlayerCheck"
- /// </summary>
- private void OnTriggerEnter2D(Collider2D collision)
- {
- if(collision.gameObject.tag == "Player")
- { // V Change this name to whatever you called the project file for the melee enemy AI
- collision.gameObject.GetComponent<MeleeEnemyAI>().playerInRange = true;
- }
- }
- private void OnTriggerExit2D(Collider2D collision)
- {
- if(collision.gameObject.tag == "Player")
- { // V Same here
- collision.gameObject.GetComponent<MeleeEnemyAI>().playerInRange = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement