Centering Colliders

How can i make it so that when I add a collider component it centers on the gameobject? Every time I try to add a collider to a prefab the collider starts at the center of the scene instead of the prefab.

Are you talking about a prefab in the prefab “scene”, or just modifying a prefab instance in a scene?

I’m talking about adding a box collider to a prefab in scene view. Is there a way to make the colliders center default to the center of the prefab in the prefab editing mode? I’m not trying to do this through a script as part of gameplay, just trying to add colliders to the walls in a roll a ball type game for a cert prep-course. In every video tutorial I’ve seen when they add a collider component to a prefab while in scene mode the colliders center starts equal to the prefabs transform.

I think I’ve isolated the problem, i was attaching the box collider to the parent gameObject for my walls, I had to add the collider component to the child gameObject for it to center properly on the prefab. Can anyone elaborate on exactly what’s happening here? I’m assuming this is intended behavior and something to do with inheritance between parent/child gameObjects.

When you add any collider it’s looking for meshes attached to the same gameobject to calculate it’s bounds and the center. If it can’t find a mesh it uses the gameobjects transform as a center and uses standard bounds.

Okay, Thanks for clarifying that for me!