godotengine / godotengine/godot

2D contact points at incorrect position, incorrect body interaction

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

Description

### Tested versions

Reproducible in 3.5.x , 3.6

### System information

Windows 10 - v3.5.3.stable.mono.official [6c814135b] .NET

### Issue description

The interaction between 2D bodies is occasionally wrong, bodies orientation get stuck at unnatural angles to the ground that should be unstable. Seem to be connected with the fact that contact points are sometimes calculated at wrong positions, well away from the bodies edges where they could touch.
![wrongcollision](https://github.com/user-attachments/assets/bb6b98fe-9981-412f-a2ca-37d6f3a85923)
RigidBody2D (in red) stuck at weird angle to a StaticBody2D (light blue), at the same time sliding freely across its surface. Blue crosses mark contact points, as reported for the rigidbody by Physics2DDirectBodyState . Wrong contact point seem to be placed at one of the vertices of the static polygon.

Normally contact points should appear where bodies edges are actually touching, and the rigidbody would fall counter clockwise to rest on its wider edge.

### Steps to reproduce

The issue observed when a RigidBody2D (polygon) slide into contact with a complex shaped StaticBody2D (polygon). Specific conditions unknown, but highly reproducible in certain situations, as in the attached project.

### Minimal reproduction project (MRP)

[testcollision.zip](https://github.com/user-attachments/files/17164303/testcollision.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached testcollision.zip project with the reported Godot versions and inspect the RigidBody2D contact points through Physics2DDirectBodyState as it slides against the complex StaticBody2D polygon. Compare the reported points with the visible body edges and the resulting orientation. Done means contacts are reported at the actual touching edges and the rigid body settles normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.