Make game object take knockback

I’m currently working on a player combat system which causes enemies to take damage if they are hit. I would also like to add something that causes them to get knocked back, however I am unsure as to how I can go about doing so. The system to detect that they are hit is there, just not the knockback. Any ideas?

You can use a Rigidbody component and then apply force to the object. If the back is opposite of the enemy’s forward position, you can use a minus to invert it and multiply it with a force value that you can calculate yourself or make fixed based on what you want. Example:

enemy.GetComponent<Rigidbody>().AddForce(-enemy.transform.forward * force);

Hope this helps!