Box Collider 2D not working

,

I made a flappy bird like game, (you can download it at https://bost.itch.io/flappy-bird-improved ) and I added box collider 2Ds to the pipes, the ground, and the bird. The bird collided with the ground, but it didn’t collide with the pipes. Please help.

It should be obvious but unless you provide more information on what you’re actually doing, how you got it set-up and configuration etc then it’s just total guesswork on what might be wrong. Please take the time to ellaborate on your set-up with description, code or pictures.

Collider sinteract by controlling which layers can interact in the layer collision matrix in the 2D physics settings. Also, certain Rigidbody2D body-types don’t interact. You don’t state what you mean by not colliding so you could mean no collision response or no callbacks and don’t specify if these pipes are triggers or not or how the pipes are moving or is the bird/camera moving only etc etc.

What are the types? Because yes, my bird has a RigidBody2D.

Ok, then, what type of RigidBody2D should I use?

The part you seem to be missing is that you seem to be assuming I have your project, understand how you’re detecting collisions and moving which is what I’d need to know to even being to answer that question.

It also might not have anything whatsoever to do with why you’re not colliding.

Please spend some of your time providing relevant detail if you want answers.

If you want to know what body-types can collide with other body-types then you can find that info here (see “Collision action matrix” section).

Maybe state what body-type the ground, bird and pipes are. If you don’t already know, not adding a Rigidbody2D makes it Static (not moving).

If you need access to the game, then the link: https://bost.itch.io/flappy-bird-improved

Playing the game won’t help answer the questions I’ve asked above. Take a look at the links I posted and maybe do some basic experiments with body-types too.

Ok, then, describing the game: There is a bird with a RigidBody2D. It also has a capsule collider 2D fit to its size. Then there is the ground. Which has a box collider 2D. The Capsule Collider 2D collides fine with the ground, but there are also pipes with Box collider 2Ds, and the bird goes straight behind the pipes.

As MelvMay stated check collision matrix in the 2D physics settings; best I can assume from the given information.

Yes, you already stated this on your first post. Maybe there’s a language barrier here I’m not sure.

All I can do is guess because you’re not providing any useful information beyond some basic description of what components you have added. Knowing you’ve got a Rigidbody2D tells me little.

  • What is the body-type of the Bird?

  • How is it being moved?

  • So you don’t have a Rigidbody2D on the Ground or Pipes right? If so, that means they are Static and should not be moved.

  • Are any of these colliders triggers?

  • What is actually moving in the game? Just the bird?

  • How are you detecting the collision with the ground and the pipes? Callbacks or queries?

  • If you are detecting the ground and not the pipes then it’s likely they are on different layers and you’ve set those layer to not collide (as described above)

  • Do you know what the Layer Collision Matrix is and how it’s used to control physics interactions?

I could continue asking lots of questions but it’s far easier to provide some useful information on how you’ve configured the bird, ground and pipes as asked above.

No, the pipes are moving.

Nope, just colliders.

No, just the pipes.

I’m not. They have different order in layer.

I’m not sure, but it’s the default one when you create the component.

No.

I’m confused on this part. As long as they have the transform component, they can be moved. Which they do.

Order in layer is rendering not physics. If you don’t know how to control physic interaction then I suggest you watch a tutorial such as this which explains it.

Because you can do something one way doesn’t mean you should. We are forced to make the appropriate changes even when devs do stuff like this. It doesn’t mean doing it is recommended, performant or scalable. If you want to do it then that’s fine but the only thing that should move in physics is a Rigidbody2D.

Honestly, I think at this point you need to look at the tutorial above which should explain this stuff.