collider2D not work

HI,
i have a problem with my wall object. i have add collider2d to it, and the player too. but my player still can pass it.

anyone have face problem similar like my problem?
please answer.
thanks

one of the Gameobjects needs to have a rigidbody component

A single collider does nothing. Your player also needs a collider2d and a rigidbody2d. You should probably watch some of the beginner physics tutorials: 2D Physics - Unity Learn

make sure your player has

  • collider2d
    • rigidbody2d
  • make sure “is trigger” is not checked
  • make sure they are all on same layer

if you have these all it will work.

if you want to use as a trigger you can also apply more than 1 collider and set 1 as the trigger

make sure that both the player and the boundary have colliders of the same type (2d or 3d) but they neeeed to be of the same type

also make sure that is trigger is not selected in any of the objects(the wall and the player)