Search Unity

Can't get cinemachine camera collision to work/achieve my desired result.

Discussion in 'Cinemachine' started by Mars91, May 5, 2022.

  1. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Being working on this "issue" for months, but I can't get camera collision to work as I want.
    Every single "complex" (but also non complex) collision cause all kind of bumpiness and stuttering, it's like collisions are not smooth at all.
    Also what if i don't care about my player occlusion or not? Can't I have just collision?


    Immagine 2022-05-05 164101.jpg
     
    Last edited: May 5, 2022
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Unfortunately your description is very vague for me to help without further information. :)

    Do you have a specific game in mind that has similar camera collision behaviour? What genre of game has the camera collision behaviour you are looking for?

    Maybe I can help you set it up or direct you to one of our sample scenes that is close enough.
     
  3. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    WIll send you a video of the issue today (I'm out of office now).
    The game is a classical third persona action advanture, camera behaviour similar to zelda/kena.
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Our "Free Look collider" sample scene could be a close match.

    You can get our samples from the Package manager:
    Screen Shot 2022-05-04 at 5.06.58 PM.png
     
  5. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Ok will give it a try but my issue is less about recognizing collision and more about how the camera react to collision and player occlusion.
    BTW will give it a try first thing tomorrow morning.
     
    gaborkb likes this.
  6. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Ok So I updated to the last version of cinemachine, took a look at the examples and no help came, I'm not using Preserve Camera Height but rather Pull Camera Forward.
    I took a 10 sec video showing you one simple case where collision are acting a bit strange.

    https://drive.google.com/file/d/1uaYeIEnvYMoVmSsDg-QNhGJlYoqhzYFQ
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the video. It looks like the camera is doing what you told it to do: pull in front of any objects that it finds itself inside of or behind. If you have lots of different objects and spin the camera quickly in their midst, then the camera will necessarily bounce around.

    What would you like it to do instead?

    Cinemachine gives a couple of options to help mitigate the bouncing.

    1. Smoothing. This tells CM to delay pulling the camera back for a little while, so if you spin the camera around and bump into lots of things, the camera won't follow the contours of your obstacles, but will hold the innermost position for a short time before pulling back.

    upload_2022-5-9_9-8-50.png

    2. Damping: There are 2 damping settings. Plain Damping will slow down the camera as it moves back from pulled-in positions, and DampingWhenOccluded will make the camera move gradually towards its pulled-in position (causing the camera to pass visibly through the obstacles). Often people put the first setting higher than the second, to minimize artifacts.
     
    gaborkb likes this.
  8. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Ok I'm tweaking things are it already looks better. There's one thing that I can't understand
    Smoothing: tells CM to delay pulling the camera back for a little while
    Damping: will slow down the camera as it moves back from pulled-in positions

    Aren't this doind the same thing?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    They are different. Smoothing will hold the innermost position, then move back. Damping controls how the move-back occurs (quickly or slowly) once it has started.