Knockback not working properly

I am making a 3D game and have added a feature that if the Bot collides with a specific object, it gets knocked back.

I am using a NavMeshAgent for the bot and this goes against the Rigidbody so I disable one and enable the other for the knockback. the problem is that the bot doesn’t get knocked back in the right direction (the direction of what it collided from) and it is also inconsistent with how far it gets knocked back.

This is the script for it:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
  
public class KnockBack : MonoBehaviour
{
    private NavMeshAgent nma = null;
    private Rigidbody rb;
  
    public bool applyKnockBack;
  
    void Start()
    {
        nma = GetComponentInParent<NavMeshAgent>();
        rb = GetComponent<Rigidbody>();
    }
  
    void Update()
    {
        if(applyKnockBack)
        {
            StartCoroutine(KnockBackCo());
            applyKnockBack = false;
        }
    }
  
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Finish" || col.gameObject.tag == "Player")
        {
            StartCoroutine(KnockBackCo());
        }
    }
  
    IEnumerator KnockBackCo()
    {
        nma.enabled = false;
        rb.isKinematic = false;
  
        rb.velocity = Vector3.forward * -15;
  
        yield return new WaitForSeconds(0.5f);
  
        nma.enabled = true;
        rb.isKinematic = true;
    }
}

You’re setting a Rigidbody’s velocity to negative 15 in forward direction, resulting in a backwards direction in world space.

When the collision occurs. Store the knockback direction by taking target position and subtract origin position and normalize it.

Vector3 knockbackDirection = (gettingKnockedBacked.transform.positon - theKnockbacker).normalized;
  
//In coroutine
rb.velocity = knockbackDirection * knockbackForce;

If someone else ends up here, I’ve read rigibodies and navmeshagents aren’t playing well together, so here’s how I did this (note that I’m a noob at C#).

//Applies knockback instantly

[SerializeField] float appliedForce = 10.0f;

NavMeshAgent agent;
Transform player;

void Awake()
{
    agent = transform.parent.GetComponentInParent<NavMeshAgent>();
    player = FindObjectOfType<PlayerHealth>().transform;
}
void Start()
{
    Vector3 _direction = transform.position - player.position; //Get direction of the knockback, opposite of source (here it's my player)
    agent.velocity = Vector3.zero; //set the navmeshagent velocity to 0
    agent.velocity = _direction * appliedForce; //add velocity to the navmeshagent with the direction
    Destroy(gameObject); //I'm using an approach where onHit I'm instantiating a prefab on the Enemy which handle the effect
}