I am trying to get the character to detect collision when punching and kicking

I am currently working on a project where I want the player to punch high objects and kick low objects. I am new to coding but I do have some experience. The code I have currently works but the player does not have to kick or punch for the enemy to disappear. This is what I currently have

void OnTriggerEnter2D(Collider2D target)
{
	if (target.tag == "Player"){
		gameObject.SetActive(false);
	}
	
}

but I would like to be something like

if character punch, make a certain character disappear and if character kick, make a certain character disappear.

you’ll need some more conditions.
First, well i guess it’s a 3D game, if you have a skined mesh for your player you maybe have a skeleton on your mesh ? If you have one, put a little trigger on the hand that punch and on the foot that kicks (a little trigger is only an empty child with a collider).

Now in your code, you have to set 2 booleans “isPunching” and “isKicking” that you set to true only during the punching/kicking animation.

The script should be on the player itself, but the trigger detection will be on the trigger on the hand
So on the hand, put a script like this

public GameObject player; //drop your player gameobject in the inspector

 void OnTriggerEnter2D(Collider2D target)
 {
     if (target.tag == "Enemy"){
         player.GetComonent</*Your player script*/>().enemyInTrigger = true;
         player.GetComonent</*Your player script*/>().target = target.gameObject;
     }
     
 }

 void OnTriggerExit2D(Collider2D target)
 {
     if (target.tag == "Enemy"){
         player.GetComonent</*Your player script*/>().enemyInTrigger = false;
         player.GetComonent</*Your player script*/>().target = null;
     }
     
 }

and on the player script something like

public bool enemyInTrigger = false;
public GameObject target;

if(enemyInTrigger && isPunching){
    target.SetActive(false);
}

@Yuvii

Thanks for the quick response. It is actually a 2D game. I currently have this for my player script.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Player: MonoBehaviour {

public float speed = 8.0f, maxVelocity= 3.0f;


private Rigidbody2D myBody;
private Animator anim;

void Awake() {
	myBody = GetComponent<Rigidbody2D> ();
	anim = GetComponent<Animator> ();
	
}

// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void FixedUpdate () {
	BunnyMoveKeyboard();

}

void BunnyMoveKeyboard() {
	float ForceX = 0f;
	float vel = Mathf.Abs (myBody.velocity.x);
	
	float h =Input.GetAxisRaw ("Horizontal");
	float k =Input.GetAxisRaw ("Vertical");
	
	if(h>0){
		
		if(vel < maxVelocity)
			ForceX = speed;
		
		Vector3 temp = transform.localScale;
		temp.x =1f;
		transform.localScale=temp;
		anim.SetBool("Hit" , true);
		
	}else if (h <0){
		
		if(vel < maxVelocity)
			ForceX = -speed;
		
		Vector3 temp = transform.localScale;
		temp.x =-1f;
		transform.localScale=temp;
		anim.SetBool("Hit" , true);
		
	}else {
		anim.SetBool("Hit" , false);

	}

	if(k>0){
		
		if(vel < maxVelocity)
			ForceX = speed;
		
		Vector3 temp = transform.localScale;
		temp.x =1f;
		transform.localScale=temp;
		anim.SetBool("Kick" , true);
		
	}else if (k <0){
		
		if(vel < maxVelocity)
			ForceX = -speed;
		
		Vector3 temp = transform.localScale;
		temp.x =-1f;
		transform.localScale=temp;
		anim.SetBool("Kick" , true);
		
	}else {
		anim.SetBool("Kick" , false);
		
	}
	
	
	
	myBody.AddForce(new Vector2(ForceX, 0));
	
}

}

and I put this script in the enemy character script

void OnTriggerEnter2D(Collider2D target)
{
	if (target.tag == "Player"){
		gameObject.SetActive(false);
	}
	
}

Will I still have to use the same concept as what you posted before for a 2D game?
The code may not be the best way to do it but that’s the only way I knew how to get the animations working.