godotengine / godotengine/godot

`body shape entered` signal called *multiple times* in the same frame, with the same shape

Open
#98,353 1 comment 3 reactions 0 assignees View on GitHub
bug topic:physics
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: v4.3.stable.mono.official [77dcf97d8]

### System information

Windows 10 - Vulkan (forward+) - dedicated

### Issue description

Sometimes the **body_shape_entered** signal is called **multiple times** in the same frame with the same shape.
When contact monitor enabled and max contact >= 2
Does not always happen.... but it is fairly consistent.
**I got a MRP setup that can reproduce this consistently in my machine**

Here's a print of the collision log:
![log1](https://github.com/user-attachments/assets/f85cb988-a68d-44df-825e-43ea00f55c63)

This caught me by surprise.

In my use-case, all was working great with _body_entered_.... and then it all broke when I changed it to _body_shape_entered_.
I was doing some stuff when the collision happened where I extracted its shape and queue_freed the body.
So the second collision call broke the game due to the collision shape not being there anymore.

So this problem doesn't seem to happen with **body_entered**... only with **body_shape_entered**...
And yes, it is the same shape_index/local_shape_index.
And objects were single shapes too.

### Steps to reproduce

- Create a player rigidbody with contact monitor enabled and at least 2 contacts
- Connect body_shape_entered to player
Result: Collisions will occasionally happen multiple times a frame

MRP example:
- Run the MRP. Check prints for multiple collisions on the same object in the same frame.
- Uncomment line 18 and 19 to see it crash instead of only printing logs when it happened

### Minimal reproduction project (MRP)

[MRP_min-shape-twice.zip](https://github.com/user-attachments/files/17448145/MRP_min-shape-twice.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running MRP_min-shape-twice.zip with the reported Godot v4.3 stable build and inspect the body_shape_entered signal path used by a RigidBody3D with contact monitoring and at least two contacts. Compare the repeated same-frame callbacks with body_entered; done means the reproduction no longer emits duplicate callbacks for the same shape while valid distinct contacts still emit normally.

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.