[HOWTO] How To: Use Cinemachine with the Dialogue System
[HOWTO] How To: Use Cinemachine with the Dialogue System
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.
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.
-
- Posts: 10
- Joined: Tue Jul 09, 2019 12:24 pm
Re: How To: Use Cinemachine with the Dialogue System
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.
Thanks you!
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.
Thanks you!
Re: How To: Use Cinemachine with the Dialogue System
Hi,
Select menu item Tools > Pixel Crushers > Dialogue System > Welcome Window. Then tick the Cinemachine checkbox.
Select menu item Tools > Pixel Crushers > Dialogue System > Welcome Window. Then tick the Cinemachine checkbox.
-
- Posts: 10
- Joined: Tue Jul 09, 2019 12:24 pm
Re: How To: Use Cinemachine with the Dialogue System
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
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
Re: How To: Use Cinemachine with the Dialogue System
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.
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.
-
- Posts: 10
- Joined: Tue Jul 09, 2019 12:24 pm
Re: How To: Use Cinemachine with the Dialogue System
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!
https://www.youtube.com/embed/JgCvM2UQ_sI
thanks!
Re: How To: Use Cinemachine with the Dialogue System
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.
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.
-
- Posts: 10
- Joined: Tue Jul 09, 2019 12:24 pm
Re: How To: Use Cinemachine with the Dialogue System
This works perfectly!
Thanks so muchTry assigning "EjemploChan (1)" to the second Dialogue System Trigger's Conversation Conversant.
Re: How To: Use Cinemachine with the Dialogue System
Glad to help. More info, BTW: Character GameObject Assignments
Re: How To: Use Cinemachine with the Dialogue System
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.
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?
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.
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?