RigidBody2D Problems changing mode

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ratty

In my project I switch my RigidBody2D player character between being RigidBody2D.MODE_CHARACTER and RigidBody2D.MODE_RIGID.

Initially going to character mode works fine, switching back to rigid mode however the player still acts like it is in character mode. If I poll get_mode() I can see it thinks it is set to MODE_RIGID, but it still does not rotate as it should.

Now, just to further confuse me, in trying to test this I created a scene as follows:
Node2D
->RigidBody2D
→ ->CollisionShape2D
→ ->Sprite
Attached a texture to the sprite, made the collision shape a circle, switched off gravity and then attached the following script to the RigidBody2D:

extends RigidBody2D

func _process(delta):
	if Input.is_action_pressed("ui_up") and get_mode() != RigidBody2D.MODE_CHARACTER: 
		print("MODE BEFORE: ", get_mode())
		set_mode(RigidBody2D.MODE_CHARACTER)
		print("MODE AFTER: ", get_mode())
	if Input.is_action_pressed("ui_down") and get_mode() != RigidBody2D.MODE_RIGID: 
		print("MODE BEFORE: ", get_mode())
		set_mode(RigidBody2D.MODE_RIGID)
		print("MODE AFTER: ", get_mode())
	if Input.is_action_pressed("ui_accept"):
		print("MODE NOW: " , get_mode())

func _integrate_forces(state):
	set_applied_torque(1000)

So, the body rotational velocity slowly accelerates, pressing up arrow switches to MODE_CHARACTER, at which point it should stop rotating (as it states here). It does not stop rotating, rather it just stops accelerating (I assume it is now ignoring the applied torque).

So I am a bit stuck, I cannot get the mode to change in my game and I cannot debug it because even a simple test case does not act as per the documentation.
The only clue I have in my game is that the body uses two collision shapes, which is the only significant way it differs from the test case.

Any suggestions much appreciated!
Cheers,
RR

:bust_in_silhouette: Reply From: Ratty

In case anyone lands here, this is related to a bug which I reported here

Hey, ever found a workaround for your problem? I have some issues with switching between MODE_RIGID and MODE_KINEMATIC…

k3nzngtn | 2020-05-01 20:09

Sorry, no, I am currently working on something else.
The link suggests it should be fixed in 3.2, if you are using that version and still get the problem perhaps you could add your issue to the bug report?

Ratty | 2020-05-02 15:40