godotengine / godotengine/godot

Pinned RigidBody2Ds act oddly after sleeping if one is the child of the other and the child wakes first

Open
#87,302 0 comments 0 reactions 0 assignees View on GitHub
bug needs testing topic:2d topic:physics
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in:
v4.2.1.stable.official [b09f793f5]
v4.0.3.stable.official [5222a99f5]
v3.5.1.stable.official [6fed1ffa3]

### System information

Godot v4.2.1.stable - Linux Mint 20.2 (Uma) - X11 - Vulkan (Forward+) - integrated AMD Unknown (RADV RENOIR) () - AMD Ryzen 7 5700U with Radeon Graphics (16 Threads)

### Issue description

If two rigidBody2Ds are pinned together with one being a child of the other and they sleep then if they are woken up by the child rigid body being moved, then the PinJoint holding them together behaves oddly (the softness of the pin is changed perhaps?)

In the video the top vehicle has all the rigid bodies as siblings and it behaves as expected.
The bottom vehicle has the wheels as children of the platform. It behaves normally IF it isn't allowed to sleep.
The first run in the video shows this

If the vehicles are allowed to come to rest and sleep first, the top one (sibling rigid bodies) still does fine upon waking, but the pin connecting the waking child of the bottom one behaves differently upon waking. Most noticeable when the vehicles are falling.

https://github.com/godotengine/godot/assets/8164842/0f02a770-7a59-440c-b371-d9651f476eb3

More notes:

in testing, it appears the method of the child moving first doesn't matter. Same result if it is done via apply_torque or apply_force in script or if you set up a separate collider that bumps into the child rigid body

after the rigid bodies start behaving oddly, if they come to rest again and the parent rigid body then wakes first, the issue is fixed until it rests again and the child is woken first

### Steps to reproduce

Condition needed to reproduce:
two rigidBody2D pinned together and one is a child of the other.
the rigid bodies must come to rest and sleep
the child rigid body must be the one to waken first (can be done via script or by impact from another object)

### Minimal reproduction project (MRP)

[Rigid2DParentChild.zip](https://github.com/godotengine/godot/files/13966295/Rigid2DParentChild.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the linked Rigid2DParentChild.zip minimal reproduction in a supported Godot build and compare sibling versus parent-child RigidBody2D setups. Reproduce the sleep state, then wake the child through movement, apply_torque, apply_force, or impact. Done means the PinJoint behaves consistently after the child wakes first, including while the bodies are falling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.