godotengine / godotengine/godot
CollisionShape2D with top_level has inconsistent position for physics
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproductible in 4.4 dev3 and 4.3 stable
### System information
Godot v4.4.dev3 - Windows 10 - Vulkan (Forward+) - NVIDIA 3060 Ti
### Issue description
When dynamically adding a collision shape with `top_level` set and then placing it through its `global_position`, the effective position (used in the physics server) seems to differ, thus giving incorrect collisions.
### Steps to reproduce
There are 2 scenes, in the project, for each. In the first one, there are 2 areas overlapping through 2 circle collision shapes. In the second scene one of the areas is left untuched, but the other one is created and placed dynamically at the exam same position as it was in the first node. Important: Note that it is added as a child of an "strangely" offset node.
You can run both scenes with "Visible Collision Shapes", in both case you should see the shapes overlap.
When the scenes are running you can left click to see the overlapping areas in the output console, in the first scene you should see something, while the second one should return an empty array.
### Minimal reproduction project (MRP)
[mrp-toplevelcollisionshape2d.zip](https://github.com/user-attachments/files/17604790/mrp-toplevelcollisionshape2d.zip)
Contributor guide
Research direction
Start by running both scenes from the linked minimal reproduction project with Visible Collision Shapes enabled, then compare the overlapping-area output after clicking. Done means a dynamically added top_level CollisionShape2D placed at the same global position produces the same effective physics position and overlap result as the scene-defined shape.
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
- Clearly specified
- Newbie friendliness
- 35/100