Enemy is not taking damage!
Hi guys, so I'm following a tutorial by GucioDevs and I have run into an error. When my player attacks, the enemy doesn't take damage. Yes, I have the player tagged as Enemy. Please help :))!
Here is my code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TurretAI : MonoBehaviour {
 
     public int curHealth;
     public int maxHealth = 5;
 
    
 
     public float distance;
     public float wakeRange;
     public float shootInterval;
     public float bulletSpeed = 100;
     public float bulletTimer;
 
     public bool lookingRight = true;
     public bool awake = false;
 
     public GameObject bullet;
     public Transform target;
     public Animator anim;
     public Transform shootPointLeft, shootPointRight;
 
     void Awake()
     {
         anim = gameObject.GetComponent<Animator>();
     }
 
     void Start()
     {
         curHealth = maxHealth;
     }
 
     void Update()
     {
         anim.SetBool("Awake", awake);
         anim.SetBool("LookingRight", lookingRight);
 
         RangeCheck();
 
         if (target.transform.position.x > transform.position.x)
         {
             lookingRight = true;
         }
 
         if (target.transform.position.x < transform.position.x)
         {
             lookingRight = false;
         }
 
         if (curHealth <= 0)
         {
             Destroy(gameObject);
         }
     }
 
     void RangeCheck()
     {
         distance = Vector3.Distance(transform.position, target.transform.position);
 
         if (distance < wakeRange)
         {
             awake = true;
 
 
         }
 
         if (distance > wakeRange)
         {
             awake = false;
         }
     }
 
     public void Attack(bool attackingRight)
     {
         bulletTimer += Time.deltaTime;
 
         if (bulletTimer >= shootInterval)
         {
             Vector2 direction = target.transform.position - transform.position;
             direction.Normalize();
 
             if (!attackingRight)
             {
                 GameObject bulletClone;
 
                 bulletClone = Instantiate(bullet, shootPointLeft.transform.position, shootPointLeft.transform.rotation) as GameObject;
                 bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bulletSpeed;
 
                 bulletTimer = 0;
             }
 
             if (attackingRight)
             {
                 GameObject bulletClone;
 
                 bulletClone = Instantiate(bullet, shootPointRight.transform.position, shootPointRight.transform.rotation) as GameObject;
                 bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bulletSpeed;
 
                 bulletTimer = 0;
             }
             
         }
     }
 
     public void Damage (int damage)
     {
         curHealth -= damage;
         gameObject.GetComponent<Animation>().Play("TinyEnemyReact");
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Idle , Move and Attack animations 0 Answers
How to enemy animation attack player 0 Answers
Enemies passing throught walls in fps game need help fixing this 0 Answers
Animations not playing correctly for FPS enemy AI 0 Answers
How would one go about creating different types of meshes for a part of the body? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                