Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RigidBody in an Area node with gravity point increases it's speed continuously #30575

Closed
Tracked by #45333
udit opened this issue Jul 14, 2019 · 10 comments
Closed
Tracked by #45333

Comments

@udit
Copy link

udit commented Jul 14, 2019

Godot version: 3.1.1

Issue description:
Expected behaviour : A RigidBody inside an Area node with gravity and gravity_point enabled, when not influenced by any other force apart from gravity of the area should not gain momemtum/speed over time.

Current behaviour: RigidBody's speed keeps increasing over time.

Steps to reproduce:

  1. In Project Settings -> General -> Physics -> 3d, set
    Default Gravity = 0,
    Default Gravity Vector = 0,0,0
    Default Linear Damp = 0
    Default Angular Damp = 0

  2. Add Spatial node and add Area node as a child, and set
    Gravity Point = on
    Gravity Vector = 0,0,0
    Gravity = 100
    Linear Damp = 0
    Angular Damp = 0

  3. Add CollisionShape as a child of Area
    Set shape as New SphereShape and increase it's radius to a sufficient size like 100

  4. Create a new scene and add RigidBody and add a CollisionShape and MeshInstance as childs
    Move the body away from 0,0,0 so it starts orbiting the gravity point.

  5. Add a camera to the scene

  6. Optional - add script to RigidBody to print velocity to confirm.

Minimal reproduction project: GravityBug.zip

Preview
GravityBug

@udit udit changed the title RigidBody in an node with gravity point increases it's speed continuously RigidBody in an Area node with gravity point increases it's speed continuously Jul 14, 2019
@harvzor
Copy link

harvzor commented Apr 6, 2020

Reproduced with the supplied project on 3.2.1.

I'm also having issues with 2D gravity points and orbits not being symmetrical.

@udit
Copy link
Author

udit commented Apr 6, 2020

@harvzor Can you elaborate on orbits not being symmetrical (probably with a minimal reproduction project)? I was working on a 2D project and 2D gravity point physics worked as expected.

@harvzor
Copy link

harvzor commented Jun 2, 2020

I'm still trying to figure this out.

The only think I've found is that setting gravity_distance_scale to 0.001 causes causes my orbit to (very) slowly get smaller and smaller.

I still have another issue with orbits not being symmetrical. I stripped my project down until the bug was no longer present so I know there's an issue with how I set things up.

@JestemStefan
Copy link
Contributor

JestemStefan commented Mar 29, 2021

I tested provided project and:
Test1: with Area LinearDamp back to default value 0.1 there is no bug. (The rigidbody have stable orbit/amplitude over 15 minutes)

Test2: With any value below 0.1 the bug is present (Tested with 0.099)

Test3: With value over 0.1 (like 0.2, 0.3, 0.4) there is no bug again

So it seems that bug is related to Damping

@Geometror
Copy link
Member

This bug is related to Bullet. Switchting to GodotPhysics fixes the problem,
the amplitude increases only very slightly over time (on the 6th decimal place) presumably due to floating point error.
As Bullet will be removed in Godot 4.0 I think this issue can be closed.

@harvzor
Copy link

harvzor commented Sep 25, 2022

I've managed to recreate the issue with the orbit not being symmetrical: https://github.com/Harvzor/godot-gravity-test

There's also a video on the repo which shows the issue: https://raw.githubusercontent.com/Harvzor/godot-gravity-test/master/godot-gravitytest.webm

I've tried tweaking many random settings, including changing the physics engine to GodotPhysics rather than default (Bullet), but the settings don't seem to make a difference.

Note that the gravity calculation is done here:

void GodotArea2D::compute_gravity(const Vector2 &p_position, Vector2 &r_gravity) const {

harvzor added a commit to harvzor/gravity-game that referenced this issue Oct 25, 2022
@bend-n
Copy link
Contributor

bend-n commented Nov 5, 2022

This bug is related to Bullet. Switchting to GodotPhysics fixes the problem, the amplitude increases only very slightly over time (on the 6th decimal place) presumably due to floating point error. As Bullet will be removed in Godot 4.0 I think this issue can be closed.

As Bullet is removed now, can this be closed?

@bend-n
Copy link
Contributor

bend-n commented Nov 5, 2022

@harvzor Can you create a separate issue?

@harvzor
Copy link

harvzor commented Nov 6, 2022

My issue is more with unstable orbits rather than the speed of objects increasing, so I think it's fair to say it's a separate issue.

Created a new issue: #68348

Probably this issue can be closed, though I haven't checked myself that GodotPhysics solves it. At least in my projects, acceleration isn't much of a problem.

@udit
Copy link
Author

udit commented Sep 2, 2023

Can confirm this issue does not happen in Godot 4. In Godot 3, it can be fixed by switching to GodotPhysics. Closing this.

@udit udit closed this as completed Sep 2, 2023
@akien-mga akien-mga added this to the 3.5 milestone Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants