I’m working in a dungeon with multiples rooms in the same scene. My problem is when to player touch the edge of the room and teleport to the next one and my Cinemachine Confiner was setup to the previous room.
What is better, create a confiner to each room and change the reference in the Cinemachine Confiner component ( change the Bounding Shape 2D, but i don’t even know if this work,) or create a camera with own confiner to each room? Or another suggestion too, because this mine sounds both awful.
Each room can come with its own vcam, with a confiner set up for it. When the player enters the room, activate the new vcam and deactivate the old one. For this you can use CinemachineTriggerAction script. There is no significant performance cost to using this approach.
This roomTransferScript reference the RoomTransfer script in the canvas (with the black image to fade in and fade out transition) that have this functions:
All that i do is call this functions in the screen fade animations (to be more accurated in time and don’t need to work with coroutine or things like this). Just trigger it and let the things happen, freeze time > screen fade to black > update the confiner > move the player to the new spawn > screen back to normal transparency > unfreeze time.
(have the fade_out_black that make the second part of the transition and the blank animation that let this image with transparency 0 all the time)
It’s working well, i can keep with one vcam and the confiner update happens when the screen is totally black, so don’t have visual impacts. BUT this post will be saved for possible future problems with this approuch haha.
UPDATE: if you wanna try this, make sure the animator component of the screen fade animations have the Update Mode setup with Unscaled Time, or this will be freeze together the rest of the game.