What's the best way to change the cinemachine confiner bounding shape at runtime?
I want to set up a system where when you walk out of one room, and no earlier, the camera moves on to show the next room. I'm currently using a Polygon Collider 2D to define the shape of rooms. Im trying to use that room shape to prevent the camera from showing what's outside the room. The only way that I've found to change where the confiner is located is to move the object that the collider is on, which isn't very useful if I want to also change the shape of the room, which is likely different from that of the previous room
Answer by Talmagett · Dec 15, 2020 at 04:06 PM
...
using Cinemachine;
public PolygonCollider2D Room;
public PolygonCollider2D Outside;
public CinemachineConfiner confiner;
private void Update(){
if (Input.GetKeyDown(KeyCode.R))
{
confiner.m_BoundingShape2D = Room;
}else if (Input.GetKeyDown(KeyCode.O))
{
confiner.m_BoundingShape2D = Outside;
}
}
Your answer
Follow this Question
Related Questions
Clamp camera within bounds of a Polygon Collider? 1 Answer
CRT Shader how optimize?! 1 Answer
Rendering a Canvas as Screen Space - Camera - Google Cardboard 0 Answers
My character walks slower when looking down? 1 Answer
First Person Controller 0 Answers