Z
Z
Zefirot2021-07-19 20:53:23
Unity
Zefirot, 2021-07-19 20:53:23

How to relink a camera to Cinemachine?

I had this camera move

if(Input.GetMouseButtonDown(0)){ CurrentPositionCamera = MainCamera.ScreenToWorldPoint(Input.mousePosition); }
        if(Input.GetMouseButton(0)){
            Vector3 DifferencePositionCamera = CurrentPositionCamera - MainCamera.ScreenToWorldPoint(Input.mousePosition);
            if(DifferencePositionCamera != PrevPositionCamera){
                MainCamera.transform.position += DifferencePositionCamera;
            }
...............

but I needed boundaries, and Cinemachine advised me, how now to switch from that control to Cinemachine?
I don’t understand much, in the training video it is shown how the camera moves behind the character, but do I need to move and zoom the camera itself?
Can you provide such examples?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SBG_P, 2021-07-19
@Zefirot

Try this: Cinemachine-Create Virtual Camera. In the created object, set CinemachineConfinder to Add Extension, then create an empty object, add Polygon Collider 2D to it, then click on Edit Collider. Select the zone as you like, and attach this object in CinemachineConfinder-Bounding Shaer 2D
It may be necessary to make Polygon Collider 2D a trigger, but I'm not sure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question