Skip to content

The Rigidbody2D cannot rotate after set the CollisionShape2D disabled first and enabled later #30551

Closed
@spkingr

Description

@spkingr

The Rigidbody2D cannot rotate if you disable the collision shape and then enable it again. But it's fine if you do nothing to the collision shape.

Godot version:
3.1.1

OS/device including version:
Windows 10

Issue description:
The rotation by apply_torque_impulse of the RigidBody2D may work incorrectly in Godot 3.1.1.
If you never disable the collision shape of the RigidBody2D, everything is normal, but if you first disable the shape use $CollisionShape2D.set_deferred('disabled', true) then after some events trigger and set it enabled with $CollisionShape2D.set_deferred('disabled', false), then the rotation looks like "broken", the node can only work with apply_central_impulse but no effect with apply_torque_impulse now.

Steps to reproduce:

func _ready():
	$CollisionShape2D.set_deferred('disabled', false)

The code above works fine, but you cannot rotate with the code below:

func _ready():
	$CollisionShape2D.set_deferred('disabled', true)
	yield(get_tree().create_timer(3), 'timeout')
	$CollisionShape2D.set_deferred('disabled', false)

This is not the actual code but for the test is enough, and I upload the very little represented project in Github: https://github.com/spkingr/test-git/tree/master/SpaceShipRotation

Minimal reproduction project:
https://github.com/spkingr/test-git/tree/master/SpaceShipRotation

The images:
cannot rotate image
normal rotation image

Activity

Raphael2048

Raphael2048 commented on Jul 14, 2019

@Raphael2048
Contributor

Unable to reproduce with latest build, seems already fixed.

spkingr

spkingr commented on Jul 14, 2019

@spkingr
Author

Unable to reproduce with latest build, seems already fixed.

So how to use the latest API in Godot 3.1 stable version to solve this bug?

Raphael2048

Raphael2048 commented on Jul 14, 2019

@Raphael2048
Contributor

Not stable version, just built with latest master source code. See here to build it https://docs.godotengine.org/en/3.1/development/compiling/index.html

realkotob

realkotob commented on Jul 17, 2019

@realkotob
Contributor

There are also daily nightly binaries here.
https://hugo.pro/projects/godot-builds/

mcbloch

mcbloch commented on Oct 6, 2019

@mcbloch

Had the same issue disabling and enabling the collision shape. I can confirm that it is fixed on a nightly build.
Extra information should this be usefull:
Godot Engine v3.2.alpha.calinou.1d9233c38
OpenGL ES 3.0 Renderer: GeForce GTX 970M/PCIe/SSE2

spkingr

spkingr commented on Feb 2, 2020

@spkingr
Author

Fixed in 3.2.

added this to the 3.2 milestone on Feb 5, 2020
lukepass

lukepass commented on Aug 4, 2020

@lukepass

Hello, I am using the version 3.2.2 and I have exactly the same problem. I cannot apply torque forces when the collision shape is disabled. Any solution?

Thanks.

Calinou

Calinou commented on Aug 4, 2020

@Calinou
Member

@lukepass Please create a new issue with a minimal reproduction project attached.

lukepass

lukepass commented on Aug 4, 2020

@lukepass

@Calinou I uploaded the project and opened a new issue:

#41024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Calinou@spkingr@KoBeWi@akien-mga@lukepass

        Issue actions

          The Rigidbody2D cannot rotate after set the CollisionShape2D disabled first and enabled later · Issue #30551 · godotengine/godot