Skip to content

Misleading warning when the z scale of a collider is 0 on 2d #984

Description

@janTatesa

Let's say we have this code snippet

use avian2d::prelude::*;
use bevy::prelude::*;

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

fn setup(mut commands: Commands) {
    commands.spawn((
        Transform {
            translation: Vec3::ZERO,
            rotation: Quat::IDENTITY,
            scale: vec3(50.0, 50.0, 0.0),
        },
        RigidBody::Dynamic,
        Collider::circle(50.0),
        ColliderDensity(1.0),
    ));
}

Running this code snippet we get

avian2d::dynamics::rigid_body::mass_properties: Dynamic rigid body 84v0 has no mass or inertia. This can cause NaN values. Consider adding a MassPropertiesBundle or a Collider with mass.

However, this is misleading as we have a mass. The actual problem is the fact that the z scale is 0. I think the library should warn the user when the z scale is 0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2DSpecific to two dimensionsA-DynamicsRelates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so onC-UsabilityA quality-of-life improvement that makes Avian easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions