Search Unity

Bug CinemachineCollider's ray origin position is incorrect

Discussion in 'Cinemachine' started by toomasio, Dec 21, 2020.

  1. toomasio

    toomasio

    Joined:
    Nov 19, 2013
    Posts:
    198
    I was tracking the players root position (feet), and using the collider extension with the combination of pull camera forward.

    The ray origin you are using to detect these collisions does not start far enough back in relation to the camera radius (I think it starts at the tracked position), so if you are tracking an object that is right against a collider you are supposed to "bump forward" to, the collision will not detect because it is starting the raycasts half way through the collider.

    I then set the offset in my transposer to match the collider radius, but the collider script does not take this offset into account either.

    I managed to fix this by putting an empty in my controller and just tracking that, but this is still a bug because people might need precise camera tracking to the objects root position. I shouldn't have to place an empty in my collider with a buffer for the radius / collider.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi, thank you for reporting this issue. I could not reproduce any issue, because probably I don't understand the problem exactly. Could you send me a project where I can reproduce the issue?

    Also, have you tried modifying the MinimumDistanceFromTarget parameter?
     
    Last edited: Dec 21, 2020
    toomasio likes this.
  3. toomasio

    toomasio

    Joined:
    Nov 19, 2013
    Posts:
    198
    To reproduce issue:

    1) New scene
    2) New Empty (follow target, look target) at position 0,0,0
    3) New Cube (floor) at position 0,-0.5, 0. Scale x/z * 20.
    4) Set up cinemachine brain on main camera
    5) Set up virtual camera on empty
    6) virtual cam setup:
    - Body - Framed Transposer, distance: 10
    - Aim - POV
    7) add cinemachine collider extension
    - make sure collision layer mask will collide with floor layer
    8) hit play and slowly look up to the sky
    9) camera will bump into floor until the direction at camPos - 0,0,0 angles past floor level...causing camera to snap back to original cam distance of framed transposer...clipping through the floor.
    10) unplay
    11) raise target height past camera collision radius
    12) play and problem should be "resolved".
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Thank you. I understand the problem now.

    At step 11), raising the target by a small epsilon is enough in my case.

    The behaviour is as expected. The ray is shot from a point that touches the collider.

    The way you fixed it is a possible solution. Also, adding a custom extension that offsets the target is another.