Cinemachine Collider Problem

I use Virtual Camera look at and follow a same target, then move target, Camera can move through wall(wall layer is default), Cinemachine Collider Against default layer.

You need collider volumes on the walls. Do you have them?

there is a Box Collider On the walls ,unity is 5.6.1, cinemachine is 2.0. I test it on edit, drag the target.

3124526–236620–New Unity Project.zip (3.41 MB)

Yes I see the problem. You need to give the wall collider some thickness in Z. If things are too thin they will fool the Cinemachine collider.

thanks very much,i will have a try.

Unity - Scripting API: Physics.ComputePenetration is a good addition for camera collisions. I have had pretty great results in tidying up issues with it.

1 Like

I am having the same problem and have been googling. This is the only thread I found so I will continue here.

I downloaded the sample project from above and have converted it to unity 2017 with cinemachine 2.0 installed for testing purposes. My actual project is in Unity 5.6 but behaves exactly the same way. To keep things simple I just want to get this sample project behaving correctly and use it to learn where I am going wrong. If I can make it work here I can figure out how to make it work in my current project. Since I am using the project already posted here and a google search for “cinemacine collider” returns this thread as one of its top 5 I thought it would be appropriate to just continue this thread as opposed to making a new one.

My problem is the same as the original poster, no matter what I try the camera will go through walls. I have set the curb feelers extra long and managed brief collision but it seems to only be for the length of the feeler. At this point the camera collides and stays away from the wall until the tracked object moves closer to the wall by the distance of the curb feelers. I can check the line of sight box and it works perfectly. The camera will move toward the tracked object like it should but that’s all it will do. A sideways collision only makes the camera move closer from the line of sight being occluded.

Above it was stated that the thickness of the wall collider was too thin. I am probably missing something here due to my complete lack of knowledge and experience with unity. When I downloaded the project the wall was set up as a cube primitive with a box collider and a scale of 100,100,10. Is this too small to be detected by cinemachines collider? I have a feeling I am missing something else completely obvious here.

I am using the project from above as an example. I imported it to Unity2017. I know this is the beta version but I am having the same trouble with Unity5.6 on a different larger project.

Yes, you are right. I was too hasty in my previous answer about the collider bounds thickness on the wall. It’s fine the way it is.

Trying it again, I find that I get good results with these settings:

Video here:
https://www.screencast.com/t/H9dAHxXF

It’s true that the Line of Sight feature seems to be doing all the work. I’ve logged an issue about the Curb Feelers not working adequately.

Thanks for the post!

1 Like

Ok I may be completely misunderstanding the way a cinemachine collider component should work as I am very new to this. I thought the collider could function without the line of sight. I was imagining it working like typical collider on a rigidbody where it would aim to not penetrate a surface and just sit still at a fixed height or slide sideways as needed as opposed to just traveling closer to the target because line of sight was occluded. Line of sight would only kick in if something got between the camera and target which wouldn’t happen if the target got closer to a wall only if something came between them without colliding first.

I think I’m lost at something regarding the Cinemachine Collider behavior.

I’m embedding a video with the issue: - Find & Share on GIPHY

A very simple use case for the collider would be for the camera to not penetrate walls while keeping its orientation or pitch/yaw values. Right now, if I’m aiming to the right, the behavior of the Cinemachine collider forces the camera to aim up, and that’s not the intended behavior for the obvious reasons.

3165849--241035--collider.PNG

The collider is broken but they are working on it. The camera looks upward to preserve its lookat target wich I assume is the head. The line of sight moves the camera in and down because the collide part isn’t doing anything.

Thank you for your answer. Yeah, it’s targeting the head, I guess I need to try and target a few meters in front of the player or something like that…? Well, I’ll wait for the next version of the collider component.

I have been using a clearshot group with 4 cameras low to high with the middle set to top priority. When ine looses view it switches to another. Using several positions like that I’m able to mimic a collision by moving the camera to the next available position. Its not as smooth as I would like but it works for now.

1 Like

I wanted to try and replace my 3rd party cam solution by Cinemachine today, but the collision feature just doesn’t work at all (I do have colliders, layer set properly in settings, etc. - double checked everything). So I’d also be happy too see a quick fix for it. :slight_smile:

The collider will still work to an extent. The line of sight feature works great. If anything puts the look target out of sight the camera will follow a straight line from its desired offset toward the target until either the target is visible or it gets to the minimum target distance limit you set. The colider with curb feelers active and set to a reasonable length will push away from walls a bit but breaks down when the follow target pushes it farther into collision than the length of the feelers at which point it penetrates and line of sight takes over. The collision component will also trigger a change in a cloud camera system making the collided camera inactive while line of sight is broken from its desired offset. You can use several cloud cameras in close range to each other to almost mimic a standard collider. When one camera position collides it switches to one that hasn’t. Not quite as smooth as just colliding because it has a finite number of positions to work with but when tweaked just right approximates it closely enough to at least be functional.

Maybe we will get a hint at timeframe for the bug fix soon. I haven’t heard anything but near future yet which is a pretty broad range of time. I do hear that Gregory is working on it and it sounded like it was pretty high on his priority list so hopefully we get word soon. Until then the cloud camera solution will have to suffice. I must say the rest of the cinemachine features have been excellent at least the ones I’ve used. It makes setting up camera fly through at the beginning of one of my levels super easy. Its a great tool and I’m glad Unity adopted it.

OK, I see I have to be more precise, sorry for that. So: “but the collision feature just doesn’t work at all in my follow object cam setup”. I have time so I’d just wait for a fix instead of implementing workarounds, it’s fine in my case. Otherwise yep, the tool is awesome, no doubt.

Does the line of sight feature in the collider component working? Even with just one vcam set to follow and look at 1 target when the camera hits a wall it should zoom in on the target until its visible. I know its not exactly collision but it does preserve line of sight. I think we are looking for similar camera setups right now. I’m not using the workaround as a final product and wasn’t suggesting you should use it as your solution. I should have been more clear. I have it set up this way for now because it was fairly easy maybe 10 minutes work and it has the camera working well enough for me to continue testing and work in other areas while Gregory works on his part. Makes it where I’m not really waiting and if they take a good bit of time fixing it I wont mind.

Mea culpa. I have discovered what went wrong in my case (so it’s not related to what others reported above, or so it seems for now during first tests). I had the follow target set, but Lookat not. As soon as I have set the Lookat property, the curb feelers and collision detection started to work. So my fault was to assume setting a follow target only would make it work.

Edit: stopped working again, so my assumption about what’s been wrong was… well, wrong. :slight_smile:

Yes. The colider does work to a usable extent. Its not quite right as you will probably find but still useful. As described above the curb feelers work some and line of sight works correctly. The only trouble I get at all is from the actual collision being able to get pushed through walls if line of sight isnt active. The curb feelers push off of the wall some but line of sight takes over too quickly. If you have a camera set at an offset of 3,3,0 when it collides it will not stay at a height of 3 instead it follows the line of sight path downwards toward the target. One the target is a distance of 1 from the wall the offset will be 1,1,0 instead of 1,3,0.

It’s been a couple of weeks coming, but the new collider is in CM 2.1, available now in beta. Please give it a try and let me know if it’s working for you.