Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Cinemachine camera stressed

Discussion in 'Cinemachine' started by M_G_ELECTRONIC, Jun 5, 2021.

  1. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
    Hello
    I have made some game in which player (car) can smash objects that use fixed joints to hold them, the car loses some speed very fast and because of that camera stressed. This happens only if speed is above 35km/h.

    Using Unity cinemachine freelook orbital camera and static.
    I have been working on that problem for one month and not find solution. In video, it can be seen that camera is stressed. The camera is not child of player. Untitled1.png

    Thank you for your help, Mark
     
  2. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
  3. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
    Thank you for help
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    It's because of the damping. When a camera is damped, it takes some time to catch up when the speed of the target changes suddenly. That is what damping is. If you don't want that behaviour, turn the FreeLook's Z damping to 0.
     
  5. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
    Hello
    I have tried your advise to turn off damping and it really lowered those suddenly changes. I actually want that behaviour with damping when there is not collisions. It gives more natural and really cool feedback.

    I now want to make compensation, to have damping on like default 0.4 and when collisions happens in high speed, the camera would slowly move towards like then player is stopping from high speed to 0 with damping. In other words included damping but have it regulated when collisions happens to move camera slowly towards and not suddenly.

    What would you suggest, thank you
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    You can make a companion script that adjusts the damping as a function of speed.

    However, in my opinion that is not the best solution because it just covers up the issue. I think the real problem lies in the motion of the car. It changes too suddenly and doesn't look realistic, and this is being revealed by the camera. A real car has a big momentum which a) would not be influenced so abruptly by that small obstacle, and b) would prevent the car from regaining speed so quickly after the collision.
     
    M_G_ELECTRONIC likes this.
  7. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
    Thank you for your help. Will focus on making more realistic collisions. If that do not not work will adjust damping via script.

    Thank you
     
  8. M_G_ELECTRONIC

    M_G_ELECTRONIC

    Joined:
    Oct 9, 2019
    Posts:
    26
    Some feedback information. I have tried all sort of things. The best and working solution was changing on player(car) Rigidbody -> collision detection from continuous dynamic to continuous speculative, the interpolation stay the same on none, otherwise camera is laggy.
    On other side objects like road sign and markers, does not effect so I left them on discrete to save on performance and interpolate to none like before.
    This setup feels more natural and also car loses 60% less speed (3-4km/h) on collision which is more close to reality, have not tried on myself yet, haha ;)

    Other collisions seems to work fine also with static objects.
    What do you thing about this solutions?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    If it looks good to you, then go with it.