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

Colliders don't work without rigid body #165

Open
SUPERCILEX opened this issue May 4, 2022 · 8 comments
Open

Colliders don't work without rigid body #165

SUPERCILEX opened this issue May 4, 2022 · 8 comments

Comments

@SUPERCILEX
Copy link
Contributor

I only need colliders and none of the other physics stuff. It the correct way to get child colliders working to use a fixed rigid body? Or can it be made so child colliders still work without the parent having a rigid body component? The old version handled this as far as I can tell.

@sebcrozet
Copy link
Member

Hi! Colliders without parents attached should still work. Did you set the proper ActiveCollisionTypes?

@SUPERCILEX
Copy link
Contributor Author

Hmmm, no I didn't use ActiveCollisionTypes. Should we be using STATIC_STATIC maybe?

BTW, I'm not quite sure what you mean by "without parents attached." This is the code we're using:

    commands
        .spawn()
        .insert(MAIN_BAG_COLLIDER.clone())
        .insert(Sensor(true))
        .insert(BAG_COLLIDER_GROUP)
        .insert(RigidBody::Fixed) // Adding this line makes the with_children colliders work. Otherwise, they don't seem to do anything.
        .with_children(|parent| {
            parent
                .spawn()
                .insert(BOUNDARY_BAG_COLLIDER.clone())
                .insert(Sensor(true))
                .insert(BAG_BOUNDARY_COLLIDER_GROUP);

            parent
                .spawn()
                .insert(LID_BAG_COLLIDER.clone())
                .insert(Sensor(true))
                .insert(BAG_LID_COLLIDER_GROUP);
        })

@sebcrozet
Copy link
Member

That's correct: STATIC_STATIC is the one.
By no parent attached I meat no rigid-body attached. I did not mean "parent" as in the Bevy parent entity.

@SUPERCILEX
Copy link
Contributor Author

Ok, just tried insert(ActiveCollisionTypes::STATIC_STATIC) on all my colliders but no dice.

@sebcrozet
Copy link
Member

Ah, that’s unfortunate. Perhaps we have a bug then. Do you have a minimal piece of code to reproduce the problem (your code above does show how the colliders are initialized, but not what you expect them to do)?
Also: if you enable the debug-renderer, with .add_plugin(RapierDebugRenderPlugin::default()), do you see that these colliders are rendered or not?

@SUPERCILEX
Copy link
Contributor Author

We've been using the colliders like this:

 let foo = rapier_context
        .intersection_with_shape(
            collider_transform.translation,
            collider_transform.rotation,
            collider,
            BAG_BOUNDARY_COLLIDER_GROUP.into(),
            None,
        );

Unfortunately I can't check the debug renderer because of #157 presumably (we're using the OrthographicCameraBundle::new_2d()).

quackercrumbs added a commit to quackercrumbs/tower-defense that referenced this issue May 15, 2022
Also update enemy config with min distance to target

Here are some References/Notes for collision updates:
- dimforge/bevy_rapier#165 (comment)
- https://rapier.rs/docs/user_vuides/bevy_plugin/colliders/#active-collider-types
  - This enabled collision detection (in our case static to static)
- https://rapier.rs/docs/user_vuides/bevy_plugin/colliders/#active-events
  - This lets us read these collision as events
- https://rapier.rs/docs/user_vuides/bevy_plugin/advanced_collision_detection
  - setup code for the event reader
@agdt3
Copy link

agdt3 commented Oct 9, 2022

For reference, I'm also getting this issue. Without adding a RigidBody::Dynamic to at least one of the colliders, nothing shows up in the intersection graph for a Sensor or the contact graph for non-Sensor colliders. Events don't show up at all regardless of the body type or the ActiveEvents flags that I set.

Cargo:

bevy = { version = "0.8.0", features = ["dynamic"] }
bevy_rapier2d = { version = "0.17.0", features = ["debug-render"] }
rand = "0.8.5"

@Fidius-jko Fidius-jko marked this as a duplicate of #634 Feb 8, 2025
@Fidius-jko
Copy link

Take event2 example and change rigid body to non dynamic and move it with bevy inspector egui

Ah, that’s unfortunate. Perhaps we have a bug then. Do you have a minimal piece of code to reproduce the problem (your code above does show how the colliders are initialized, but not what you expect them to do)? Also: if you enable the debug-renderer, with .add_plugin(RapierDebugRenderPlugin::default()), do you see that these colliders are rendered or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants