I upgraded to Cinemachine 3 recently and reworked my camera system with it. It’s been great so far, but I’ve hit a roadblock and need some advice.
The structure is basically a CameraManager at the top of the scene and the cinemachine player cameras as children. the manager holds state and has an api for switching between them using priority. There are several cameras but only two important for this question.
- UprightCamera - Orbital Follow (3-ring) and Rotation Composer, pretty standard.
- AimCamera - 3rd person follow and 3rd person aim extension, goes over the right shoulder.
Our KCC has previously been set up so that each camera would maintain a MovementHeading quaternion in state. The movement system would use this value to define forward in the movement loop.
It took me a few tries to set up an aim camera. I’ve had drafts that were orbital with an offset and 3rd person rigs. But in my latest system I tried to set it up with the model laid out in the cinemachine samples. There’s a player core object (though mine has no parent) that implements IInputAxisOwner and uses an InputAxisController to rotate with player input. Its position is locked to the player’s position.
This works great, but now I’m having issues blending between the two. As I debugged it I realized it’s because I now have two models working simultaneously: the orbital follow uses player input to drive its position and rotation around a central object, and the aim camera uses player input to drive the rotation of a central object it’s rigidly fixed to.
I can’t figure out how to sync these two pairs of axes. At first I had them each controlled with their own input axes, but responding to the same input action. But I noticed that after running around for a bit, the “forward” would drift apart between the two cameras, and one would become askew. I figured out that this was primarily happening during camera blends, but after futzing with the blend settings and input settings I couldn’t get it to stop.
I also refactored the movement system to use the player core pivot object to get its forward direction, instead of the camera rotation. It seemed a little more direct. But it didn’t solve the issue and I’m not married to the idea.
I’m curious how other people implement this from a design perspective. What I’m trying now is driving the orbital camera’s input axes using the input axis values of the player core pivot object, but either I’m missing something or there’s no way to override the input axes on the orbital camera with another instance. And it seems kind of backwards.
I also looked into how the Cinemachine samples approached it, but they didn’t. The Aim Camera samples use a 3rd person rig that’s similar to an orbital, but not orbital. I could do this as a backup but I don’t really want to unless it’s best practice for some reason.
I’m curious to hear about how other people have approached this. I drew up a little system design if it’s helpful. Thanks in advance.
