godot-box2d icon indicating copy to clipboard operation
godot-box2d copied to clipboard

Incorrect behavior when implementing 2D planet attractors using Area2D nodes

Open SirLich opened this issue 2 years ago • 2 comments

Describe the bug In Godot, it's possible to use Area2D nodes, to define custom gravity settings. Example, using Godot Physics:

image

The large planet is a static body, with a gravity well defined thusly:

image

image

The smaller planets are RigidBody2D, and stick to the larger planet. Here are my physics settings:

image

When using Box2D, the following behaviors are observed:

  • Originally, gravity well functions
  • After a few seconds, the balls start to roll down even though they shouldn't!!
  • Eventually they go flying off the planet with extreme speed

image

Changing the default physics settings (e.g., setting anti gravity), doesn't appear to fix the problem.

To Reproduce Steps to reproduce the behavior: I will provide a test

Expected behavior A clear and concise description of what you expected to happen.

Project I will add one later! Sorry.

Versions (please complete the following information):

  • OS: Windows
  • Godot: 4.2
  • Box2d: Custom version you sent me. Version.txt says 'v0.9.4', but I don't know if that's correct.

SirLich avatar Dec 08 '23 12:12 SirLich

@Ughuuu here is the project: area2dgravity.zip

It's all setup for you to play! Just press f5.

What you should see:

image

Once you've confirmed it's working, change the physics server to Box2D, and observe the chaos!

SirLich avatar Dec 08 '23 20:12 SirLich

It is a bit strange indeed. Will need to investigate it.

Ughuuu avatar Dec 08 '23 21:12 Ughuuu