Hi! I’m working on my first Unity project and I’m stuck at something. In order to limit the range to which my camera can move I created a hollow cylinder in Blender and added a mesh collider to it, hoping that the camera would stay inside the cylinder. But the camera moves through the cylinder to the outside and then can’t get back in. I checked the normals in Blender and they are in the correct directions.
I am aware that this should be possible to do with a script but my coding skills are extremely limited.
I think your issue is a physics related one. Two objects can not occupy the same space. Unity resolves any conflicts like these by moving the offending object until it no longer violates the laws of physics. An object with no Rigidbody is not bound by physics. Also see isKinematic and position/rotation locks in the Rigidbody inspector panel.
If you really just want to prevent an object from getting further away from a certain point in space than a certain fixed value, just learn how to check and manipulate positions in code. Things to read up on in the docs: Transform.position and Vector3.Distance().