Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

[Help] Cinemachine - How to keep camera higher than terrain?

Discussion in 'Cinemachine' started by chenjiadian, Jun 11, 2018.

  1. chenjiadian

    chenjiadian

    Joined:
    Jun 4, 2018
    Posts:
    2
    Hello, I am using Cinemachine to control my mainCamera, and there is a problem that bothers me a lot. Can I change main Camera's position manually or use custom interpolation during the transition between two virtual camera? In most case, Cinemachine do the interpolation automatically and perfectly, but sometimes the camera will cross the terrain and go below the terrain, so we can see the other side of terrain. I can get the y position of the ground so I can avoid the camera entering the terrain if i can change the position of camera manually. However simply change transform,position of camera seems not working during the transition(or with Follow). What I want to do is just to keep camera's y higher than ground in our game. I have tried use collider but it seems to only push camera forward rather than rise the camera higher. Can you give me any hints? Thanks.
     
    Last edited: Jun 11, 2018
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,217
    Currently there's no way for you to have fine control over what happens in a vcam transition. That said, the latest CM 2.2 (available now in Preview) has added some hints to the vcam that affect how they transition. It might do the job for you. We're expecting the release to be public by the end of the month. Also the collider has been improved to better handle terrains.

    In the meantime, you could try adding a little script to the camera (the Main Camera with the brain, not the vcam) that post-processes what CM does, to push it out of the ground every frame. You would do that in LateUpdate, and you would need to set the script execution order to make sure your script executes after CinemachineBrain.
     
  3. chenjiadian

    chenjiadian

    Joined:
    Jun 4, 2018
    Posts:
    2
    Thank you for replying. I read some source code and finally realized I need to make sure my code which push the camera out of the ground need to be executed after CinemachineBrain.
    Actually, another reason why I try to customize the vcam transition is because sometimes it behaves so weirdly. For example, when two vcams are placed in opposite direction, brain will try to approach the second vcam, and suddenly turn around. But I think the better way is to use Bezier or other curve to avoid suddenly turning around, because it might result in strange change in light and shadow or other effect. Is there any way to avoid camera suddenly turn around?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,217
    Yes, in the new CM there are "blend hint" settings that will help with this.