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

weird behavior of a small cube #207

Open
rlidwka opened this issue Oct 28, 2023 · 0 comments
Open

weird behavior of a small cube #207

rlidwka opened this issue Oct 28, 2023 · 0 comments
Labels
bug Something isn't working solver Relates to constraints, joints or the solver

Comments

@rlidwka
Copy link

rlidwka commented Oct 28, 2023

  1. create a small cube and an infinite plane
  2. wait until cube settles down and sleeps
  3. throw it into the air with bevy_inspector_egui

after it comes back to the ground, 3 weird things start happening:

  1. cube is constantly sliding on the ground (all physics engines do that to some extent, don't know why)
  2. occasionally, cube goes to sleep for 1 frame, then wakes up
  3. occasionally, cube jumps upwards/rotates by itself (with f32 precision, it flies away, but with f64 it comes back down to continue her dance)

I'm using cube size=0.02. With size=0.2 effect is still there, but less noticeable. Friction is default (=0.3, avg).

See demo here:
https://www.youtube.com/watch?v=z_ke6jVr-BE

bevy = "0.11.3"
bevy-inspector-egui = "0.20.0"
bevy_xpbd_3d = { git = "https://github.com/Jondolf/bevy_xpbd", branch = "main", features = ["debug-plugin", "f64", "3d", "collider-from-mesh"], default-features = false }
use bevy::math::DVec3;
use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_xpbd_3d::prelude as xpbd;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(xpbd::PhysicsPlugins::default())
        .add_plugins(WorldInspectorPlugin::new())
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(0.3, 0.3, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..Default::default()
    });

    commands.spawn((
        xpbd::RigidBody::Static,
        xpbd::Collider::halfspace(DVec3::Y),
        xpbd::Restitution::new(0.7),
    ));

    commands.spawn((
        xpbd::RigidBody::Dynamic,
        SpatialBundle::from_transform(
            Transform::from_xyz(0.1, 0.8, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
        ),
        xpbd::Collider::cuboid(0.02, 0.02, 0.02),
    ));
}
@Jondolf Jondolf added bug Something isn't working solver Relates to constraints, joints or the solver labels Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solver Relates to constraints, joints or the solver
Projects
None yet
Development

No branches or pull requests

2 participants