[HOWTO] How To: Use Cinemachine with the Dialogue System

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Use Cinemachine with the Dialogue System

Post by Tony Li »

This is a brief description of how to use Cinemachine with the Dialogue System. Cinemachine is a Unity feature that you can enable in Unity's Package Manager window. It provides advanced camera control.

Cinemachine uses components called Cinemachine Virtual Cameras (vcams for short) that define how the camera should work (e.g., follow targets, zoom in on a location, etc.). Each vcam has a Priority value. Cinemachine uses the vcam that has the highest Priority. Normally you'll have a vcam that controls the camera during regular gameplay, for example following the player character.

You can add another vcam to the scene that focuses on a conversation NPC. Give it a Priority of 0 so Cinemachine doesn't use it during regular play. When the conversation starts, increase its Priority to something higher than 10.

There are two ways you can control a vcam's Priority in a conversation:

1. Add a Cinemachine Priority On Dialogue Event component to the NPC. Set the dropdown to OnConversation. Assign the vcam. Configure it to increase the vcam's Priority during conversations.

2. Or use the CinemachinePriority() sequencer command.

You can use both. For example, use Cinemachine Priority On Dialogue Event to prioritize a vcam that focuses on the NPC at the start of the conversation. Say that during the conversation the NPC points to a mysterious object that she wants the player to investigate. Use CinemachinePriority() to prioritize a different vcam that focuses on the mysterious object. Later, use another CinemachinePriority() to drop the priority of the mysterious object vcam. This will cause the NPC's vcam to take effect again.


If your project pauses the game during conversations (i.e., sets Time.timeScale to zero), tick the camera's Cinemachine Brain > Ignore Time Scale checkbox. This will allow Cinemachine to keep working even if a conversation pauses the game.
Waru_GameDev
Posts: 10
Joined: Tue Jul 09, 2019 12:24 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Waru_GameDev »

Hi!
How is going?
I have a problem!
I added the package of cinemamachine from the third party support.
But Cinemachine Priority On Dialogue Event Didn't appear.

Image

Thanks you!
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Tony Li »

Hi,

Select menu item Tools > Pixel Crushers > Dialogue System > Welcome Window. Then tick the Cinemachine checkbox.
Waru_GameDev
Posts: 10
Joined: Tue Jul 09, 2019 12:24 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Waru_GameDev »

Thanks!
But now I have another problem...
I used with two npc of my game, both have different conversations and that work well, but when I go to the second npc the camera of cinema machine go to the first npc.
I am using the Cinemachine Priority On Dialogue Event for character and assigned differents vcam but only change to the first vcam.
Best
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Tony Li »

Hi,

When you start the second conversation, check the priorities on both vcams. Make sure the second vcam's priority is the highest priority in the scene.
Waru_GameDev
Posts: 10
Joined: Tue Jul 09, 2019 12:24 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Waru_GameDev »

Here is a video about the issue, for some reason only the first vcam change the priority with the two conversation.

https://www.youtube.com/embed/JgCvM2UQ_sI

thanks!
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Tony Li »

Try assigning "EjemploChan (1)" to the second Dialogue System Trigger's Conversation Conversant.

If the actor in your dialogue database is named "EjemploChan", then it's probably choosing the GameObject named "EjemploChan".

To confirm this, temporarily set the Dialogue Manager's Debug Level to Info. When you start a conversation, it will report:

Dialogue System: Starting conversation 'XXX' with actor=AAA and conversant=BBB

Make sure it's using the correct actor for BBB.
Waru_GameDev
Posts: 10
Joined: Tue Jul 09, 2019 12:24 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Waru_GameDev »

This works perfectly!
Try assigning "EjemploChan (1)" to the second Dialogue System Trigger's Conversation Conversant.
Thanks so much :D
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Tony Li »

Glad to help. More info, BTW: Character GameObject Assignments
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: How To: Use Cinemachine with the Dialogue System

Post by Strig »

Hello! I couldn't find a similar thrad, but I decided to post here to see if anyone had a similar issue:

I'm currently using Cinemachine Shake in a project, but I've faced a problem whenever I enter a Conversation or Bark: the next time the screen shakes, I get a NullReference. The only way I could find of fixing this was to create an OnExecute() event and call CinemachineShake.SetInstance(), as seen below.
Captura de Tela (348).png
Captura de Tela (348).png (41.01 KiB) Viewed 3873 times
It... works, but it keeps bugging me even now, because I have no idea what is causing the error in the first place. To make matters worse, these events are on NPCs, which means most of the time I have to replace references in different scenes.

Does anyone know what is the cause of this issue? And what can I do to solve it in a more practical way?
Post Reply