To start with I am beginner game dev, and new to using Cinemachine. I am trying to restrict the camera exposing the edge of the screen. I know that i have to add a Cinemachine Confiner and to have a collider. But my map is generating procedural and so I will have to add the collider programmatically and also somehow tie the collider to the Cinemachine Confiner and I don’t know how, or couldn’t find the necessary documentation…
Your collider is a PolygonCollider2D, right?
If you’re using the TileMap, you can have it generate a CompositeCollider2D programmatically, and you can use that.
Once you have the collider, just populate the fields of the CinemachineConfiner component:
Thanks for the quick answer, I am now looking into ways of creating a polygon collider 2D, cause mine was a Box Collider 2D. The camera looks exactly like that.
I made a mistake in my earlier post: the TileMap can generate a CompositeCollider2D, not a PolygonCollider2D. This generated shape can be used as the bounding shape.
Thanks a lot! If anyone is intrested I made it by creating a Composite Collider, enabling isTrigger, then adding my boxCollider2D as a child of the said Composite Collider, with a tick at “Used by Composite” and then editing the boxCollider2D size and offset from the script.