- Home /
how to know if my cinemachine camera is colliding with the confiner inside code
ok so first of all I have searched and have not been able to find anything on the internet that can help me with this so pls don't say this is a duplicate question or has been answered in another post cause I didn't find anything according to unity 2020 or even close to this version.
so I have a 2d camera with a cinemachine virtual camera I only use it for confined and it works and everything is ok.
but I have an auto travel option for my camera which basically takes a position and moves the camera to that point.
the question here is that I want to know when my camera is touching the cinemachines confiner collider and can't move any further so basically what is the way of knowing [inside code] that your camera is touching the confiners edge so then you'd be able to execute some code on that event
Answer by spartan_nm · Nov 04, 2021 at 09:42 AM
with a help of a friend[Pure#7790] inside the brackeys discord server I was able to find the solution:
in here you can checkout the CameraWasDisplaced method which solved the problem for me https://docs.unity3d.com/Packages/com.unity.cinemachine@2.1/api/Cinemachine.CinemachineConfiner.html
this method will return true during the frames that our camera is being displaced by the confined which is exactly what i wanted but the documents were a little bit unclear
What about in confiner2D? There is not that method. What to do in this case ?
Answer by cyberbizniz · Apr 24 at 07:42 PM
What about for confiner2D ? There is no such method in Confiner2D class. What to do in this case ?