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

Rigidbody connected with a Pinjoint accelerates for no reason

Open Pyrocreep opened this issue 1 year ago • 4 comments

Describe the bug Rigidbody seems to keep gaining momentum when attached to a staticbody using a pinjoint

To Reproduce Steps to reproduce the behavior:

  1. Make a static body
  2. Make a rigidbody
  3. Attach them using a pinjoint

Project https://drive.google.com/drive/folders/1HsmJvfHw9jBL3yek3hZRsB3BhkWgjW4X?usp=sharing

Versions (please complete the following information):

  • OS: Windows
  • Godot 4.2
  • Box2d 2.4.1

Pyrocreep avatar Jan 10 '24 15:01 Pyrocreep

https://github.com/appsinacup/godot-box2d/assets/52212525/eb3f4628-a7f9-48fb-84b8-e0bc9bf3360a

I just moved the CollisionShape2D

Az-qianchen avatar Jan 11 '24 12:01 Az-qianchen

2024-01-11.201449.mp4 I just moved the CollisionShape2D

yeah, ive had this issue too but thought it was my code or something lol

Pyrocreep avatar Jan 11 '24 13:01 Pyrocreep

Right, I think the issue is related to the center of mass. Since you move the shape, but the anchor remains the same, the object has a very weird inertia. So this is the default behaviour of box2d in this case. From what I saw box2d doesn't like objects like this that don't have shape in center or close to center.

What is the use case of this though? Why can't you move the rigidbody instead?

If you think about it from a physical point of view, it's kind of weird if the shape isn't centered to zero on the body.

Ughuuu avatar Jan 11 '24 14:01 Ughuuu

Right, I think the issue is related to the center of mass. Since you move the shape, but the anchor remains the same, the object has a very weird inertia. So this is the default behaviour of box2d in this case. From what I saw box2d doesn't like objects like this that don't have shape in center or close to center.

What is the use case of this though? Why can't you move the rigidbody instead?

If you think about it from a physical point of view, it's kind of weird if the shape isn't centered to zero on the body.

i just enciutered an issue in my pinball game, where the paddles(on a pinjoint) worked fine, then i scaled them down(by remaking the sprite and remaking the collision shape) lined it up in the exact same way, and all of a sudden it didnt work

Ethanol54006 avatar May 06 '24 21:05 Ethanol54006