Search Unity

FramingTransposer Perspective Camera Issues

Discussion in 'Cinemachine' started by Jakub-Slaby, Sep 11, 2021.

  1. Jakub-Slaby

    Jakub-Slaby

    Joined:
    May 6, 2017
    Posts:
    10
    Hello! I've been trying to use the Cinemachine Framing Transposer to track a Target group that will consist of two playable characters, but I noticed that when the camera is not set at a right angle the bounding box calculations are quite off.

    To illustrate the problem I've set up two targets in a group with a overhead camera at 90 degrees.
    You can see a nice an tight bounding box which is the desired effect.

    framingTransposer1.png

    When testing with a any other camera angle than a straight angle I see that the calculation is quite a bit off.

    framingTransposer2.png

    Becoming even worse when the distance between the targets is bigger, with the calculation favouring the objects further away.

    I started digging in to creating a custom framing transposed based off the default one and was able to find
    ComputeGroupBounds
    , and in there the code that fixes the positioning of the camera for perspective camera, also causes the bad re-calculation of the bounding box.

    When removed the bounding box is better - I wouldn't say correct cause the positioning is not adjusted.
    But here is the result.
    framingTransposer3.png

    I don't fully understand the math that is calculated in
    GetScreenSpaceGroupBoundingBox
    to be able to modify it but it would be great if you guys considered supporting angled camera views with Framing Transposer as it would really help in top down games.

    I'm aware that the documentation specifically states that the Framing Transposer is meant to look at a straight angle.

    With Orthographic cameras the transposer behaves properly, with tight bounding box around objects.
     
    Gregoryl likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,723
    Thank you for brining this up. It's a tricky problem, but probably solvable. We will add it to our list.
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,723
    Update: we have a fix for this. PR is in flight. Should be included with the next CM release.
     
  4. Jakub-Slaby

    Jakub-Slaby

    Joined:
    May 6, 2017
    Posts:
    10
    Thanks @Gregoryl, that's great! Will give it a go when it's updated in the package.
     
    Gregoryl likes this.
  5. Jakub-Slaby

    Jakub-Slaby

    Joined:
    May 6, 2017
    Posts:
    10
    Hey @Gregoryl,
    I've been checking out the last few updates to Cinemachine looking at the changes to above issue.
    I've recorded a quick video to show the behaviour I'm still seeing, in some cases it does now work, but at some other group arrangements it behaves a bit more uncontrolled.



    If there is anything else you'd like me to send to debug this issue please let me know, hope that helps a bit to show what the issue is.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,723
    I can't see the video
     
  7. Jakub-Slaby

    Jakub-Slaby

    Joined:
    May 6, 2017
    Posts:
    10
    Ah, sorry should be ok now, selected wrong permissions ;(
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,723
    Sorry for the long delay, I was on vacation.
    I can see the video now. Interesting!
    Can you send me the project?
     
  9. Jakub-Slaby

    Jakub-Slaby

    Joined:
    May 6, 2017
    Posts:
    10
    Hi Gregoryl,
    I'll make a small repro project next weekend and send it over.