How would I go about creating a knock back for an object based on direction of where the player or enemy attacks?
I believe this would go in something like void onCollisionEnter2D(Collision2D col)
// vec1 is the player and vec2 is the enemy
movdir = Mathf.Rad2Deg(Mathf.Atan2(vec1.transform.position.y - vec2.transform.position.y, vec2.transform.position.x - vec1.transform.position.x));
if (col.gameObject.tag == "Enemy") {
rb.AddForce(movedir * thrust);
}
I believe I got most of it right, but looking for clarification.