Search Unity

Combining framing transposer with free look vcam?

Discussion in 'Cinemachine' started by Ranocchio, Nov 22, 2017.

  1. Ranocchio

    Ranocchio

    Joined:
    Apr 25, 2017
    Posts:
    6
    I have a very specific camera set-up that I was hoping to implement in my game and I've been trying to figure out if I can do it with Cinemachine. After playing with it a bit I think this is the closest to what I want:

    • A vcam with framing transposer body behavior following my player by default.
    • When the player presses down the middle mouse button the camera acts as a free look camera around the player for the duration the button is pressed.
    • When the button is released it turns back into framing transposer, only now it's looking from the angle that was set in free look.

    I like the look of the framing transposer because I'm making a click to move game so I want more of a 2D camera, but I want to let the player adjust the angle of the camera when it suits them. I'm not sure how to blend between these two so that they have the same position and that it only activates free look when middle mouse button is down. Does anyone have any suggestions on how to implement this set-up?

    Thanks
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Since the Framing Transposer uses the vcam's angle as input and never alters it, you can probably get what you're looking for by simply adding controls to manipulate the vcam's rotation in its transform: Y rotation for the yaw, and X rotation for the pitch.
     
  3. Ranocchio

    Ranocchio

    Joined:
    Apr 25, 2017
    Posts:
    6
    So you’re saying to drop the free look camera and just write a script that manipulates the framing transposer vcam?

    If so, my main reason for wanting to use the free look is I like the degree you can rotate it across the three different rigs. I want to let players choose more extreme angles to really show off the scenery. Just using a vcam that rotates in place doesn’t get the same effect and it seems like a waste to write a vcam controller that mimics free look if it already exists.
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Why not just keep the free-look camera and disable Recenter Heading? Perhaps I'm not fully understanding the problem - what is the desired behaviour after the button press, freelook and let go. What would you like the camera to do between free-look release and the framing transposer cam - anything?
     
  5. Ranocchio

    Ranocchio

    Joined:
    Apr 25, 2017
    Posts:
    6
    I might be thinking about this wrong actually so I’m gonna drop references to specific cameras and just describe the behavior of the camera that I’d like.

    So normally I’d want the camera to follow the player without changing its angle and while only moving along its local X and Y axis. Think of it like basically a 2D camera, kind of like the default camera in a Smash Bros game without the zoom for lack of a better example.

    Then, when the player presses and holds the middle mouse button the camera, starting from the same position and rotation the camera has been in, becomes movable with the mouse. It now looks at the player and orbits around and can move from high above the player to down beside it.

    When the player releases the middle mouse button the camera doesn’t move or rotate, it just stays in position looking at the player but now resumes the original 2d camera behavior following the player along the local X and Y axis from its new position.

    Essentially it’s like having one camera with two different behaviors.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Are you sure you mean camera-local X and Y? Not X-Z plane?
    I'm still gonna push for my idea about manipulating the FramingTransposer vcam's rotation. For radius you twiddle the FramingTransposer's Camera Distance field (maybe you could tie this to the mouse wheel). This will give you all the angles and views you might want. The FreeLook is limited to the shell defined by the 3 rigs, and seems to me to be less suited to your purpose, if I understand you correctly.
     
  7. Ranocchio

    Ranocchio

    Joined:
    Apr 25, 2017
    Posts:
    6
    I liked the idea of using the free look because it had the rotation with mouse input already built in, but maybe you're right, it does seem simpler to just add the rotation to the framing transposer vcam. I'll try implementing it and see how it goes.

    Edit: I tried playing around with the vcam rotation in the editor and I think you're right, this is the way to go. What would be the best way to provide mouse input to this vcam?
     
    Last edited: Nov 24, 2017
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You could check for mouse events in Update, and manipulate the transform directly. Just add a custom script to the vcam, and handle the mouse events in its Update(). In the same function, you could also adjust the Framing Transposer's Camera Distance Field. Have a look at ScriptingExample.cs (in the examples folder) for some clues about how to access a vcam's CM components.