How to not make the enemy rotate when it collides with a projectile?

When the player shoots a projectile at the enemy, the enemy will rotate since it has a rigidbody. How would I prevent this without removing the rigidbody component since it is needed for other stuff. (both projectile and enemy has rb2d)

In Unity, you can prevent an object with a Rigidbody 2D component from rotating when it collides with another object by setting its freezeRotation property to true. This will lock the object’s rotation to its current value and prevent it from being affected by collisions or other forces.

To set the freezeRotation property, you can do the following:

Select the enemy game object in the scene hierarchy or the project view.
In the Inspector window, find the Rigidbody 2D component and expand it.
Check the box next to the freezeRotation property.

Alternatively, you can also set the freezeRotation property programmatically in your script by using the rigidbody2D.freezeRotation property. For example:
Rigidbody2D rb2d = GetComponent();

// Lock the object's rotation
rb2d.freezeRotation = true;

I hope this helps! Let me know if you have any other questions.