Invisible barrier transform.Translate error

I’m trying to add invisible barriers to my game, what I’ve done is made a cube, turned off mesh rendering, and added a box collider. with it added and positioned correctly, I can still move straight through it. Any idea why this is? i saw that it could be a problem with using transform.Translate, so I’m not really sure what to do to fix it.

Translate won’t care for anything physic. You need a character controller with character motor (it’s a script already attache to the prefab usually), or you need to detect the collision by script, then adjust your position. In that case, the collision event will be raised if your character’s collider have a kinematic rigidbody and if the box have a non-kinematic one.