Search Unity

Isolate soft zones for translation and orbital rotation

Discussion in 'Cinemachine' started by rustofelees, Oct 19, 2017.

  1. rustofelees

    rustofelees

    Joined:
    Apr 22, 2013
    Posts:
    26
    Just started using Cinemachine and it's great so far. However I'm somewhat at a loss when trying to implement a soft zone for the cameras aim position while a player is translating through the world, while also implementing an input based orbital cam, that rotates and pitches around a point in space, simultaneously.

    I've started with the Free Look brain, have changed all three rigs to have a soft/dead zones of 0, have tied the input axis to Mouse X and Y respectively, and have been able to get the orbit part working correctly. However, because there isn't a soft/dead zone, the camera constantly looks at that point when the player moves through the world (thus no soft follow).

    Is it possible to have a soft zone for translation and another for camera rotation upon user input? Am I thinking about this correctly?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
  3. rustofelees

    rustofelees

    Joined:
    Apr 22, 2013
    Posts:
    26
    Thank you! I worked with the new version today and it does have the functionality I'm looking for minus a couple things. I'm uploading an inspector view of my free look camera and a video to demonstrate a few issues.

    The first part of the video shows that as I orbit around the x axis, this camera does appear to orbit around a single point and the target position doesn't change. However, in the second part of the video, I show that the when I rotate around the y axis, the cameras target position moves horizontally. This seems really odd. Can you verify this is a bug, or is there something in my inspector that doesn't look right?

    The last part of the video tries to demonstrate the difficulty of having really tight control of the camera while still having a long dampening when the camera comes to a rest . In order to have the camera appear like it comes to a rest after releasing control, i have to extend my decel time to around .5. It provides a soft ease out on the camera when the player stops providing input. However, if I move my mouse right and then immediately to the left, there's a long delay between when the camera starts moving the opposite way (which I'm assuming is related to the long decel time). Is this a bug or is there a better way of getting this type of behavior?

    Video
    https://drive.google.com/file/d/0B-UtqM7_7RmPcVJZQkxXZjBQUXM/view?usp=sharing

    Thanks again!
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you set the dead zone width and height to zero in all 3 rigs, the spurious horizontal movement will disappear.
    As for the accel/decel problem, I think you've tripped over a piece of imperfect logic in the axis handler. Let me have a look and get back to you.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I would also reduce the H/V damping time in the Aim. 15 seconds is awfully high, and while the damping is going on you will get some deviation from center when you orbit.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
  7. rustofelees

    rustofelees

    Joined:
    Apr 22, 2013
    Posts:
    26
    @Gregoryl, I just updated to RC6 and can confirm that the accel/decel issue has been resolved. Awesome work!

    In regards to updating the dead zone to be 0 for all three rigs - I tried this, and while the target ultimately ends up in the middle of the soft zone (where the Vertical Orbit problem goes away), this still presents a few issues.

    First, it doesn't seem like I have control over how fast the target goes back to the middle of the soft zone once the deceleration period has ended [see the first part of the video for this]. If this is the case, the problem still exists if the player tries to vertically orbit while the target is settling back to the middle of the soft zone [see the second part of the video for this].

    Also, it would be great to be able to use a dead zone, so that the cameras target isn't always directly in the middle of the screen.

    My gut tells me that I'm still missing a critical piece of information about how these systems all work together, but I haven't been able to figure out how to get these parameters to play nicely together for what I'm trying to do.

    Video to demonstrate aforementioned issues:
    https://drive.google.com/file/d/0B-UtqM7_7RmPWC1SQ1BIYVhMams/view?usp=sharing

    Thank you again for being so helpful - I appreciate your time!
     

    Attached Files:

  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I'm having a hard time following the video - not sure what's going on in there. It would help if I understood a little more about what was going on in the scene. Maybe you could add audio commentary, where you just describe what the target is doing and what you're doing.

    So the FreeLook has 3 different damping settings.
    1. The Body damping. As the target moves, the vcam's idea of where the target is in world space is damped by this setting
    2. The Aim damping. The composer's idea of where the target is in screen space is damped by this setting
    3. The axis acce/decel setting. This effectively damps the user's axis input
    The orbiting will always occur around the vcam's idea of where the follow target is. This is influenced by the Body damping. If this damping is nonzero and the target is moving, then the orbiting will not always be exactly around the target.

    Can you describe a little what your scene is, and what you would like the camera to do?
     
  9. rustofelees

    rustofelees

    Joined:
    Apr 22, 2013
    Posts:
    26
    Hey Greg,

    I made two videos for you.

    The first one is a custom solution that gives me most of what I need, but has some flaws in that it doesn't tie into cinemachine in some regards.

    The second video demonstrates the difficulties in achieving the results of the first video while using cinemachine.

    Video 1:
    https://drive.google.com/file/d/0B-UtqM7_7RmPaVhpbTZIaWw2N2s/view?usp=sharing

    Video 2:
    https://drive.google.com/file/d/0B-UtqM7_7RmPdFVmSzFwVjhkRnM/view?usp=sharing

    Please let me know if I can clarify anything in the videos.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Thanks for making those videos, I'm understanding a little better now. Let me just validate.

    In the first video, what you have is the camera hard-looking at and orbiting around a point in space, which is following your character in a damped way. The camera always orbits around that follower point, which is always centered in the screen. It's as though the follower point were holding a giant selfie-stick with the camera on it, and swinging it around in response to the orbit control.

    You like this behaviour, with the exception that you have no way to control the follower point's damping from a screen-space perspective. You would like it to keep up with the player in such a way that the player remains on-screen. There's no way to do that because the follower knows nothing about screen space.

    In the second video, what you have is a little more complex. You have the camera body following the player with damping, and orbiting around that damped point. In addition, you have also given it a composer, which is the equivalent of putting a little demon on the end of the selfie stick, with instructions to also follow the target, but with a totally different damping algorithm: his is screen-space, while the rig is damping in world-space.

    You don't like this behaviour, because the two damping algorithms don't seem to play well together in this use-case.

    The camera is re-orienting itself because you gave the composer a hard zone. The position damping pushes the target out of the hard zone, so the camera re-orients (not repositions) itself to put the target back on the screen - that's the job of the Aim section. And it takes a long time to settle to the center because that's what you told it to do: by setting the Aim H/V damping to 5, you've said "take 5 seconds to settle to the center". So the position/orientation relationship is all out of whack.

    So what's the solution? I see 2 possibilities.

    1. Use a free-look in rigid selfie-stick mode. Go back to the zero-damping hard-lookAt rig and the damped follow target. Improve the position damping algorithm of your follow target by taking camera distance and FOV into account, and keep the follow target close enough so that the real target stays on-screen.

    2. Get rid of the FreeLook and use an ordinary vcam, with a FramingTransposer in the Body, and no LookAt target. This is a special transposer that does composition in screen space by moving the camera (what you are looking for), without modifying the camera's aim. With the FramingTransposer, the vcam's rotation in its transform defines its forward vector, and thus its relationship to the follow target. For the axis control, you'll need a script that directly modifies the vcam's Y and X rotations in response to the user's axis input. Play with the rotation in the inspector first, to see if it's what you want.