Question by 
               Bunnyman742 · Aug 21, 2019 at 07:16 AM · 
                raycastingraycasthit2dsendmessagesend message  
              
 
              Using raycast2D to have two AI damage each other
void update
     RaycastHit2D hitboxInfo = Physics2D.Raycast(hitboxDetection.position, Vector2.up, hitboxDetectionHeight);
     if (hitboxInfo.collider.tag == "Enemy")
     {
         playerMovement = false;
         if (attacking == false)
         {
             attacking = true;
             AttackEnemy(attackDamage);
             attacking = false;
         }
     }
 public void AttackEnemy(int attackDamage)
 {
     RaycastHit2D hit = Physics2D.Raycast(hitboxDetection.position, Vector2.up, hitboxDetectionHeight);
     if (hit.collider.tag == "Enemy")
     {
         hit.collider.gameObject.SendMessage("TakeDamage", attackDamage);
     }
 }
 public void TakeDamage(int damageAmount)
 {
     currentHealth -= damageAmount;
     if (currentHealth <= 0)
     {
         currentHealth = 0;
         alive = false;
         //gameObject.SetActive (false);
     }
 }
Two functions are not in void update
The raycast 2D won't send the TakeDamage message to the enemy to deal the damage and it needs to be able to send its attack damage to the enemy AI it hits so that if its attackDamage changes, the enemy AI will receive more damage each attack.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                