2D Attack For Fighting Game

So , I was scripting a simple 2D punch like attack system. So far I have a working Player which can move although I disabled jump for some testing purposes and an Enemy which follows the player to a certain distance. So the problem I am facing is that , what I have is a attack collider on an empty object which is a child of the Player and it is near the arm of my player and my script checks if the enemy is inside the Trigger and if the user presses the fire01 button then it will get the enemy game object using the tag and play the hit animation but what happens is when the object is inside the trigger and I press the button it only works only once unless I move a bit and then attack.

Note: Some lines have been commented out because I was not able to get it to work properly and this is my first ever question so forgive me if I did some mistake while writing this question . Also I did this on my own without any tutorials so sorry if I am doing something in a wrong way.

The Scripts are down below

Player Script:

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

public class Player : MonoBehaviour {

public Vector2 Movement;
public float Speed;
public int JumpSpeed;
public LayerMask Ground;
public bool IsGrounded;
public GameObject Feet;
public bool Attack;
public GameObject AttackCollider;

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

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

    if (!Attack)
    {
        Movement = new Vector2(Input.GetAxisRaw("Horizontal") * Speed * Time.deltaTime, 0f);
        gameObject.GetComponent<Rigidbody2D>().velocity = Movement;
        gameObject.GetComponent<Animator>().SetFloat("X", Input.GetAxisRaw("Horizontal"));
        IsGrounded = Physics2D.OverlapCircle(Feet.transform.position, 1, Ground);
        gameObject.GetComponent<Animator>().SetBool("Grounded", Physics2D.OverlapCircle(Feet.transform.position, 1, Ground));
    }

    if (IsGrounded)
    {
        if (Input.GetButtonDown("Jump"))
        {
            // gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f,gameObject.GetComponent<Rigidbody2D>().mass * JumpSpeed * Time.deltaTime));
            //gameObject.transform.Translate(new Vector2(0f, +JumpSpeed+Time.deltaTime));
           //     gameObject.GetComponent<Rigidbody2D>().gravityScale = -40; //Find A Better System
            Invoke("GravityChange", 0.2f);
        }
    }

    if (Input.GetButtonDown("Fire1"))
    {
        gameObject.GetComponent<Animator>().SetBool("Punch1", true);
        Attack = true;
       //AttackCollider.SetActive(true);
        Invoke("Attack_Cancel", 0.3f);
    }
}

void GravityChange()
{
    //gameObject.GetComponent<Rigidbody2D>().gravityScale = 30;
}

void Attack_Cancel()
{
    gameObject.GetComponent<Animator>().SetBool("Punch1", false);
    Attack = false;
    //AttackCollider.SetActive(false);
}

}

Enemy Script:

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

public class Enemy : MonoBehaviour {

public bool Move = true;
public GameObject Player;
public float Speed;
public Vector2 PlayerMotion;

// Use this for initialization
void Start () {
    Move = true;
    Invoke("OnMove", 0.2f);
}

// Update is called once per frame
void Update () {
    PlayerMotion = Player.transform.position - gameObject.transform.position;
    PlayerMotion = PlayerMotion.normalized;

    if (Move) 
    {
        gameObject.transform.Translate(new Vector2(PlayerMotion.x * Time.deltaTime * Speed, 0f));
    }
}

private void OnTriggerEnter2D(Collider2D collision)
{
    Move = false;
    gameObject.GetComponent<Animator>().SetFloat("X", 0f);
}

private void OnTriggerExit2D (Collider2D collision)
{
    Move = true;
    gameObject.GetComponent<Animator>().SetFloat("X", PlayerMotion.x);
}

private void OnMove()
{
    Move = true;
    gameObject.GetComponent<Animator>().SetFloat("X", PlayerMotion.x);
}

public void OnHit()
{
    gameObject.GetComponent<Animator>().Play("Freeza_Hit");
}

}

Hit Script:

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

public class Hit : MonoBehaviour {

public GameObject Enemy_Obj;
// Use this for initializat
void Start () {
	
}

// Update is called once per frame
void Update () {
   Enemy_Obj = GameObject.FindGameObjectWithTag("Enemy");
}

public void OnTriggerStay2D(Collider2D collision)
{
    if (collision.tag == "Enemy")
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Invoke("Hit_Active", 0.1f);
            Debug.Log("Hit");
        }
    }
}

void Hit_Active()
{
    Enemy_Obj.GetComponent<Enemy>().OnHit();
}

}

Thanks In Advance . I will forever be grateful to you :slight_smile:

For any one having the same problem, all I had to do to fix it was to change the rigid body to never sleep.