Search Unity

[Feature request] Camera Area clamp

Discussion in 'Cinemachine' started by PedroDuran, Aug 19, 2017.

  1. PedroDuran

    PedroDuran

    Joined:
    Aug 19, 2014
    Posts:
    32
    It would be cool if we can clamp the position of cinemachine camera by an area.

    A camera that only moves inside an area ( like a trigger zone ) where the camera position gets clamped to that area.

    This gif explain the idea:

     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Great feature idea, thanks.
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Another idea would be to not have collision on the camera position but ON the near plane, and move the near plane before moving the camera when there is an occluder between the target and camera. Movie and animation often have the camera at impossible location to get the best frame (ie inside the ground, the wal etc ...).

    However to accommodate interactive navigation (in this example a third person camera whee you can see the entirety of the character, head to foot), the camera must be clamped to a certain distance of the near plane (especially with big obstacle like wall), so the player moving toward the camera is notified there is something. Without this clamp system, you would get perfect framing of the character but with no tell there is something that prevent movement, I set the distance such that the character is in medium shoot once near the obstacle (we don't see his foot or legs, only from the torso up to the head, basically hiding the navigation signifier).

    In general moving the near plane and the camera independently help smoother transition and better framing expressiveness, near plane movement can be harsh as long as the frame is stable. As long as nothing actually intersect the near plane, in fact anticipation of collision with the whole frustrum can help predict clean near plane movement.

    I used to do this using a bunch of raycast from the target to the camera position and setting the near plane to the closest point. I wanted to perfect the technique by having a full collider swept from target to near plane, but didn't make it so far yet, mostly because there is scaling (perspective frustrum have a pyramidal shape) and also because it's a bit beyond my skills (had to figure out FOV math, some collision math, etc ...).

    I think Armalur discovered the technique independently too!
     
    Gregoryl likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @neoshaman This is a great idea. It might get a little tricky, though, the devil is in the details. Moving the camera itself has the advantage of requiring only a single raycast, because the camera can be considered to be a point. As you mention, one would have to consider the 4 corners of the near clip plane, requiring 4 raycasts. But it's still a great idea, and we have it on our list of things to experiment with. Thanks for the suggestion.
     
    neoshaman likes this.
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    IN fact you have to consider the whole plane itself, which scale with distance lol Else you will miss small occluder, and why I investigating volume (cube) collider. One idea I just got is to have a bunch of trigger volume across the frustrum to detect intersection and interpolate accordingly. But I don't know the cost of volume vs raycast. It's on the backlog so I'm not going back to it anytime soon either lol
     
  6. Huknar

    Huknar

    Joined:
    Mar 6, 2015
    Posts:
    40
    I'd be super interested in this too. The game I am currently making has a custom written solution (but not so perfect) for clamping the camera to an area, so if Cinemachine included this I'd really consider moving some of my camera over to it.

    Is there any way this can be coded ourselves (without a great deal of hassle) to work with cinemachine? I have yet to dive into so I don't know how open it is. In fact, if it is open enough to implement additional behaviors like collision and clamping ourselves that'd be a great start.

    My game requires a complex selection of camera setups, that you can find in the Silent Hill series, so this would be a really nice addition for me. :)
     
    PedroDuran likes this.
  7. PedroDuran

    PedroDuran

    Joined:
    Aug 19, 2014
    Posts:
    32
    Thank you for considering my idea :) this gonna be a great addiction to Cinemachine ;)
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @PedroDev Give it a spin in 2.1 and let us know what you think.
     
    PedroDuran likes this.
  9. PedroDuran

    PedroDuran

    Joined:
    Aug 19, 2014
    Posts:
    32
    I tried the Beta of Cinemacine 2.1 .. It's cinemachine confiner right ?? It seems to work really nice :) Thank you ! :)