bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

Entity are overlapping at spawn, which can result in explosive behavior.

Open Cupnfish opened this issue 2 years ago • 2 comments
trafficstars

https://github.com/Jondolf/bevy_xpbd/assets/40173605/327633fd-fa88-441f-9281-9ca4370a883c

When this situation occurs, the movement of the sphere feels a bit exaggerated. Is there an efficient way to limit this? I'm using the following approach to limit it:

fn limit_velocity(mut velocitys: Query<&mut LinearVelocity, Changed<LinearVelocity>>) {
    const MAX_LINVEL_Y: f32 = 150.;
    for mut velocity in velocitys.iter_mut() {
        velocity.0 = velocity.0.min(Vec2::splat(MAX_LINVEL_Y));
        // if velocity.y > MAX_LINVEL_Y {
        //     velocity.y = MAX_LINVEL_Y;
        // }
    }
}

The commented part is what I previously used when using Bevy Rapier, and I'm not sure if something is missing when I migrated it. The previous settings don't seem to work anymore.

Cupnfish avatar Nov 15 '23 16:11 Cupnfish

Hello! I am developing a 3d version of this and having the same problem. I think it is related to the size of objects when they are spawning and it possibly overlaps. How are you spawning your combined circles?

benjamin-cates avatar Dec 01 '23 01:12 benjamin-cates

@benjamin-cates I have already solved this problem. Although it is indeed related to the size during generation, sometimes this kind of overlap is unavoidable. After adjusting the SubstepCount to an appropriate value, the game runs as expected. You can also give it a try (usually by reducing it).

.insert_resource(SubstepCount(3))

Cupnfish avatar Dec 01 '23 11:12 Cupnfish