Skip to content

RapierPhysicsPlugin requires generics #501

@Jondolf

Description

@Jondolf

Trying to add the plugin the way that most Bevy plugins are added fails:

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, RapierPhysicsPlugin::default()))
        .run();
}

It fails because Rust cannot infer the type for PhysicsHooks. Instead, you need to do something like this:

RapierPhysicsPlugin::<()>::default()

or:

RapierPhysicsPlugin::<NoUserData>::default()

This isn't obvious for new users, and is especially confusing because the plugin has no documentation example (outside the website's general usage guides). The use of NoUserData or the concept of physics hooks isn't even explained on the website before the "Advanced collision-detection" section, even though the plugin initialization is essentially the first thing that a user has to do. It shouldn't be necessary to use generics here.

Additionally, limiting the user to a single PhysicsHooks type feels rather limiting and annoying from a composability standpoint. But that's another issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Integrationvery bevy specificC-EnhancementNew feature or requestD-DifficultNeeds strong technical background, domain knowledge, or impacts are high, needs testing...P-LowS-not-startedWork has not started

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions