Page 1 of 3

Cinemachine Zoom

Posted: Mon Mar 06, 2023 4:40 pm
by Shinos
I followed the guide in https://www.pixelcrushers.com/phpbb/vie ... 4&start=20 and i was using cinemachine for the dialogues, but how can i make different Zoom in for the dialogues? without cinemachine i would just use for example Zoom2D(speaker, 8, 2) , but what about cinemachine? is there a simple way or should i design some kind of custom script?

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 5:48 pm
by Tony Li
No need for custom scripting. You can set up one or more vcams and use a [url-https://www.pixelcrushers.com/dialogue_ ... event.html]Cinemachine Priority On Dialogue Event[/url] component on the NPC, or a sequencer commands such as CinemachinePriority() and CinemachineTarget() as described in the first post of the thread you linked.

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 7:51 pm
by Shinos
Yes i already understood how to set up the cinemachine with the Dialogue system, but what i wanted to achieve was different zooming with the same cinemachine camera, as you can easily do with the command "Zoom2D(//, //, //)" put in the dialogues where i want to achieve different zooming effects, i think you missed the point of my question

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 8:58 pm
by Tony Li
You can use CinemachineTarget() and CinemachindPriority() to do that.

Cinemachine by default smoothly moves the camera (blends) over time.

For example, if you want to zoom over time from a wide angle to a closeup, set up two vcams: one that focuses on the target from a wide angle, and another that focuses on the target close up. Use CinemachineTarget() to change both vcams' targets to the subject (e.g., NPC). Then use CinemachinePriority() to cut to the wide angle, and then CinemachinePriority() again to set the closeup vcam's priority higher so it transitions to the closeup.

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 9:02 pm
by Shinos
Yes but that's what i was trying to avoid,, to set a lot of different cameras just for different zooming , if i use normal cameras with the zoom2d i can just use 1 camera and change the zoom as many times as i want, but if i for example want 5 different types of zoom with the approach you suggested now i have to set 5 different Cinemachines, what i wanted to know was if there was a similiar approach to the zoom2d settings but that operated with the Ortho size of the single cinemachine used , because basically that's the only thing changing between all the other virtual cameras i would have to create using the approach you suggested.

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 9:04 pm
by Tony Li
Nothing is built into the Dialogue System for that, but you could write your own sequencer command that changes a vcam's distance over time.

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 9:06 pm
by Shinos
Tony Li wrote: Mon Mar 06, 2023 9:04 pm Nothing is built into the Dialogue System for that, but you could write your own sequencer command that changes a vcam's distance over time.
That's what i meant to understand with this post and it's also the reason of why i said earlier if i had to make a custom script or command for that,, if so how could i do it? it would be useful to have a command for this to just change the ortho size of a cinemachine virtual camera in the sequence menu, just like the zoom2d does to the regular cameras, it seems pretty inefficent to me to create hundreds of different cameras just for different zoom effect.
Please how could i write my own sequencer command for this?

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 9:42 pm
by Tony Li
Hi,

I suggest duplicating SequencerCommandCinemachineTarget.cs and renaming it something like SequencerCommandCinemachineZoom.cs. Then change the "void Awake()" method to an "IEnumerator Start()" method so you can run it as a coroutine that changes the vcam's ortho distance instead of its LookAt/Follow properties.

More info: Custom Sequencer Commands

Re: Cinemachine Zoom

Posted: Mon Mar 06, 2023 10:02 pm
by Shinos
Tony Li wrote: Mon Mar 06, 2023 9:42 pm Hi,

I suggest duplicating SequencerCommandCinemachineTarget.cs and renaming it something like SequencerCommandCinemachineZoom.cs. Then change the "void Awake()" method to an "IEnumerator Start()" method so you can run it as a coroutine that changes the vcam's ortho distance instead of its LookAt/Follow properties.

More info: Custom Sequencer Commands
Thank you for helping me but i think i need a little more help , i feel kinda dumb but i i tried to do as you said and i couldn't get it to work, , when you have some spare time could you provide further assistance? why would i use an IEnumerator method here? i think i am missing something in how doing a custom sequencer command works, i tried to watch also your video on youtube but it didn't help for this

Re: Cinemachine Zoom

Posted: Tue Mar 07, 2023 11:09 am
by Tony Li
Here's the CinemachineZoom() sequencer command:

DS_CinemachineZoom_2023-03-07.unitypackage

Syntax:

CinemachineZoom(vcam, zoom, [duration])
  • vcam: The name of a GameObject containing a CinemachineVirtualCamera.
  • zoom: The lens orthograpic size.
  • duration: Duration over which to transition to zoom. (Default: 0 [instant])