best function to rotate to mouse position unity 2d

Because 2D Physics isn’t controlled via the Transform, it works the other way around. The Rigidbody2D is in control of the Transform; it writes to it when the simulation runs.

Note: You can use code-tags when posting code for better formatting.