addforce depends on players position?

Hello all, I have a melee weapon, it checks with raycast is there is enemy at certain distance and do damage.
Also I want enemy to be pushed away from player during attacks.

Weapon code part:

if (Physics.Raycast(ray, out hit, hitDistance))
			{
				if (hit.collider.gameObject.tag == "enemy")
				{
					Vector3 myPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z);
					
					hit.collider.GetComponent<AI>().DoDamge(Damage,myPos);
					
					audio.clip = hitSound[Random.Range (0, hitSound.Length)];
					audio.volume = aVolume;
					audio.Play();
				}

Enemy code part

	public void DoDamge(int damage, Vector3 dir)
	{
		Health -= damage;
		rigidbody.AddForce (-dir, ForceMode.Impulse);
		Debug.Log(dir);
	}

This one works wrong…

nvm, solved.

Maybe you could tell what you did to fix the problem.