It’s working for me. I’m using CM 2.1 RC4.
What behaviour are you expecting, and what are you getting?
Note that even in a 2D scene, the box collider needs to be a 3D object, whose position is such that the camera will be inside it. So, if the camera is 10m in front of the game plane, then the box collider needs to include the plane where the camera is: either position it at z = -10, or have its Z size big enough to include the z=-10 plane.
I just want to share my thoughts on the way the Confiner 2D works, or should works more specifically. I struggled for some time before I realized something : Each time I assign a new PolygonShape2D (for example) to the confiner, I had to call “InvalidatePathCache” method. To me it is not intuitive because the confiner let us know (the client of the API) of its internal “poutine” and it should not work that way. Of course, when I assign a new Shape to the confier, it should invalidate automatically its internal cache, that’s the contract I have with the confiner. Suggestion, instead of having a public member m_BoundingShape2D, give us a method or a property, in that case you could invalidate the cache automatically each time a user set a new BoundingShape… That my 2 cents…
hey, cinimachine 2.5 does not have an check box option of confining screen edge, and I am having problems to confine the camera in a 2D polygon collier. Have any idea what may went wrong? I was following what this tutorial said and It did not work out. It is step 5 and 6.
Hi! Is this already fixed? I dont know if that is the problem I am having but everytime I set new bounds (at runtime) they dont work properly, But if I reload the scene with the new bounds set before hand they do work!
Edit: Yes it was exactly that. I just added the InvalidatePathCache() before changing the bounds and now it works. At least I only wasted like 4 hours on this!
Something else to add to the list of fixes with Confiner2D: When editing a Polygon Collider 2D’s points while the editor is running the game, it will completely break the cinemachine camera. I say completely, but essentially when the screen edge hits the updated collider, it will–what it appears to do anyway–is immediately teleport(or move quickly with enough dampening) the camera to a location that is within the polygoncollider2d’s original boundaries before being changed. If I double the size of my polygon2d collider’s extents–this is a very significant unity space jump. Took me several hours to figure out this bug. Was honestly ready to throw cinemachine in the trash and just code my own solution, but lucked out and saw the above mentioned bug and tested it out myself in the editor’s game window while playing to see if it was a similar issue. It’s more than assigning a new collider–even changing the collider’s extents seems to cause mayhem.
@robcbryant For performance reasons, the confiner will not check every frame if the polygon points changed, and will just use cached values. If you change the polygon, you must call confiner.InvalidatePathCache().
Hi, just a quick question, my project use 2020.3.7f1 version of unity and the last version available for cinemachine seems to be the 2.6.4 where i cannot find the new confiner 2d extension.
Good morning!
Sorry for the distraction, but I need help.
I have not found any clues on either google or youtube.
I have several locations on the same stage.
And for each location, I need to make a CameraConfiner so that the camera does not go beyond the edges of the location.
I know how to do it in one location, but I don’t know how to do it in all locations.
And if you teleport, the player teleports, and the camera stays at the first location, because the confiner blocks any exit from the camera.
I have a 2D Top-Down game.