From the RigidBody2D's description:
(...) You do not control a RigidBody2D directly. Instead you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties.
Note: You should not change a RigidBody2D’s
linear_velocity every frame or even very often. If you need to directly affect the body’s state, use
_integrate_forces, which allows you to directly access the physics state.
You can't change the a RigidBody2D's
rotation anywhere outside of
_integrate_forces. Even if you change it in
_physics_process, it will jump back to its initial value after you release the key, that's why you need a
rot variable there.
To change the rotation, there are a few ways:
state.transform = Transform2D(rotation + 10, position)
angular_velocity = 10