0 votes

In my project I switch my RigidBody2D player character between being RigidBody2D.MODECHARACTER and RigidBody2D.MODERIGID.

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 getmode() I can see it thinks it is set to MODERIGID, 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:
-> ->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())
        print("MODE AFTER: ", get_mode())
    if Input.is_action_pressed("ui_down") and get_mode() != RigidBody2D.MODE_RIGID: 
        print("MODE BEFORE: ", get_mode())
        print("MODE AFTER: ", get_mode())
    if Input.is_action_pressed("ui_accept"):
        print("MODE NOW: " , get_mode())

func _integrate_forces(state):

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!

asked Jul 19 in Engine by Ratty (32 points)

1 Answer

0 votes

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

answered Aug 16 by Ratty (32 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.