My current needs are probably much simpler than a powerhouse package like Cinemachine, but I’m sure if I can weed out the advanced stuff I can make this happen. In my 2.5d game I’m running into issues with getting the camera shots I want. I’ve watched all of the Unity Learn videos on Cinemachine and have perused the forums a bit but I think the biggest issue I’m running into is just have no idea what all of these options do—and then when I tweak them I can’t make any sense of what’s happening because of it.
The major things I’m bumping up against are:
1.) Is there any way to make sure cameras stay on one side of the scene? For example, I need my cameras to never go beyond -15 on the Z axis. I’ve tried making this happen by using confiners/colliders to trap the cameras on one side because sometimes when following target groups they’ll try to flip and move all over the place. This works but feels wrong?
2.) I’m having trouble following target groups and having the camera actually put all members of the group into the frame. Ideally, I want the camera to either move or zoom in when there are less units in the group and move or zoom out when there are more. This kind of works, but paired with my issue from point #2 above, it either looks way to zoomed out when there are too few units or way too zoomed in where there are too many. Many times, manipulating the follow offset does literally nothing even when I pump it to astronomical values.
Examples:
One example of the target group thing is that sometimes it feels like the camera just doesn’t even try to get all of the objects in the shot. Here’s a screenshot. I’ve got to push the z-axis and/or zoom SO far out to make all of the objects fit on the screen but the shot gets ruined if anyone moves.
You should be able to do this by using vcams with Framing Transposer in Body and Do Nothing ion Aim.
Use CinemachinTargetGroup to hold the targets.
When you add/remove members to/from the group, you should lerp their weights from/to 0 over a short time in order to avoid camera pops in the event that a live vcam is looking at the group.
You set up the rotations of the vcams in their transforms. With Do Nothing in Aim, CM will never change the vcam rotation, so cameras will stay on the correct side of the playing field.
You say you want the cameras to zoom… do you mean that you want them to stay in the same place and change their FOV to accommodate the group members, or do you mean that you want the cameras to back up or move forwards in order to frame the group? If the latter, then changing the target distance in the vcam will have no effect, since the group framing will override that to reposition the camera.
There is a bug in GroupFraming that may be causing the framing issues you’re having. This has been fixed in the very very latest version of CM.
Thanks so much for this @Gregoryl I’m getting way closer now with your feedback. I was using an older version of CM but just upgraded to the newest version and tried again. Framing Composer + No Aim has helped a ton—not having any issues with rotation anymore—but I still can’t find a setting that guarantees every one of my target group objects will be in the shot as they move around.
A Brackeys vid helped me make my own camera controller that pretty much does exactly what I want in terms of framing the shot, here’s a clip of what I’m seeing for reference.
The tl;dr of the video is you use Bounds to encapsulate your target group then define the center point of the group and point your camera at it. Then, you adjust your zoom depending on the furthest x distance of the bounds. However, I tweaked the code to zoom based on the x or z distance depending on which was larger which resulted in the exact kind of zooming I was looking for.
I’m trying to translate this into Cinemachine and still can’t make it happen. All of my units are in target groups and are weighted appropriately and I’m using essentially the default settings for the camera:
Where both the Follow and LookAt are the target group. In play mode when I adjust Tracked Object Offset literally nothing happens. When I adjust Group Framing Size nothing happens. I had to add the Cinemachine Camera Offset extension to get it to raise up off the ground at all but even then, when my units move around some fall out of the camera shot. Even when playing with Minimum and Maximum FOV it either zooms WAY too far out or zooms in so much it cuts objects out of the shot.
Surely this is user error but now that you can kind of see what I’m trying to accomplish maybe you could help me get it over the finish line? Thanks again!
Also, in terms of lerping the object’s weight to 0 before removing it from the group—it this post the best way to do that? It seems a bit clunky and the person posting the answer said they weren’t the most technical person on the team
Hey @Gregoryl I was able to figure this out from continuing to play around with your suggestions. It really just came down to implementing what you said and setting a reasonable offset value using the cinema chine offset extension. Thank you!