Search Unity

Free look Mouse ScrollWheel and block axis control

Discussion in 'Cinemachine' started by Onsterion, Feb 12, 2018.

  1. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Hi,

    In some 3rd person camera experience especially in MMORPGs you can rotate the camera pressing right click in the mouse and you can control the Z position of the camera using the Mouse ScrollWheel, have any way to do this with cinemachine or i have to do a custom script?



    Regards.-
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Pretty easy to set up with a simple script to adjust vcam parameters.
    Can you be a little more specific about what kind of camera movement you want?
    e.g. rotate means camera aim adjustment or orbital rotation about some look-at target?
    and z-position means...?
     
  3. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Yes, i recorded from my game with my scripted camera, you can see the rotation only pressing some button (in this case mouse right click - drag) and you can see the camera moving away and get closer (in this case using mousewheel).

    Video:




    Regards.-
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    ok, so you're talking about orbiting around the target.
    Mousewheel controls the radius. Got it.
    What happens when you drag vertically? Is the camera moving in a sphere around the target, or is it describing a cylinder? Or some other shape?
     
  5. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    In sphere around the target.
     
  6. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    I used a hierarchy childs for move different axis and z.




    And i am interested in remove all my camera system and add all cinemachine.




    Regards.-
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    ok. Use an ordinary vcam, with Transposer and Composer. Set the transposer Binding Mode to World.

    Nothing out-of-the-box. You will need to make a custom script to manipulate the transposer's m_FollowOffset field based on your mouse input. For rotation, rotate it. For zooming, scale it. You will need to set limits on the vertical rotation, to avoid making the camera look straight up or straight down (vcams get confused when they do).

    You can access it as follows:
    vcam.GetCinemachineComponent<CinemachineTransposer>().m_FollowOffset = bla;
     
    Onsterion likes this.
  8. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    it's a shame that there is nothing out of the box to handle this kind of third-person behavior :'(
     
  9. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Well, I finded the expected behavior passing the mouse wheel value in to the radius value in the Orbit array using the Freelook component.

    Video:

     
    Gregoryl likes this.