Skip to content

About

Repository to reproduce an issue with Godot 4 around bouncing of bodies

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Minimal Reproduction of Godot 4 issue

See the related Godot Engine issue. This code can be used to reproduce that scenario.

⚠ That issue has since been closed. It was deemed "user error" and "wrong expectations [from the developer]", not a bug or missing documentation or tooling. Because I feel others might run into these same gotchas as I did, I will leave up this repository. Before the info on how to reproduce the situation, let me start with what I found out and how I worked around it.

⚠️ Notice about updates

Note that this repository is provided "as-is" and will most likely not receive any (security) updates.

Root cause and solution/workaround

The root cause of the bug summarized from the more extensive reply is (paraphrased):

Combining Control and Node2D nodes can give the expectation of them not having special interaction, but sometimes they might break when combined.

In short: the advice there and from the other Contributor is to not mix them at all.

Later I found that there's a Control node called SubViewportContainer which can hold a SubViewport which seems meant for my scenario: layout with Control notes, and part of that layout dedicated to 2D physics.

You can check my other sample repository to see how that would work.

Issue demonstrated by this repository

Steps:

  1. Clone this repository
  2. Enable debug options to see collisions and shapes
  3. Run it in Godot 4 (I used 4.0 on Windows 10)
  • Result: ball slides into the polygon
  • Expected: ball slightly bouncing on the polygon

Variant: reset the transform Scale.x on CharacterBody2D to 1.

  • Result: ball bounces off the polygon super fast
  • Expected: ball only slightly bouncing on the polygon

Videos of the unexpected and expected results:

Or, for as long as the links work (since the raw videos were uploaded via Godot's issues, which may get archived):


Video of the ❌ unexpected result with the base repro:

repro-godot-bounce-bug-unexpected-result.mp4

Video of the ❌ unexpected variant with non-flipped CharacterBody2D polygon:

repro-godot-bounce-bug-expected-result-variant.mp4

Video of the expected result (after removing ColorRect from the aforementioned tree):

repro-godot-bounce-bug-expected-result.mp4

Closing remarks

I'm learning Godot at the time of writing so don't take all this as expert advice. Still, I'm hoping it may help someone.

About

Repository to reproduce an issue with Godot 4 around bouncing of bodies

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors