Camera follow player walking during sequence
-
- Posts: 7
- Joined: Sun May 05, 2024 11:37 am
Camera follow player walking during sequence
Hello, how are you all doing today? I hope all is well!
I have been using the dialogue system for a few days and it has really helped me to progress my game a lot.
I want to try something where I use the MoveTo(); sequence command to move the character to a trigger game object whilst a conversation is taking place, but I want the camera to follow them (the main actor) until they reach the game object, I am wondering if there is any camera command for this. This is a 2d game and I am using orthographic camera.
Thank you,
Kind regards!
I have been using the dialogue system for a few days and it has really helped me to progress my game a lot.
I want to try something where I use the MoveTo(); sequence command to move the character to a trigger game object whilst a conversation is taking place, but I want the camera to follow them (the main actor) until they reach the game object, I am wondering if there is any camera command for this. This is a 2d game and I am using orthographic camera.
Thank you,
Kind regards!
Re: Camera follow player walking during sequence
Hi,
If you were in 3D, I'd recommend using the LiveCamera() sequencer command that follows the subject, versus the Camera() sequencer command that records the destination position when the command starts and moves the camera there without following the subject. The 2D equivalent of Camera() is Zoom2D(), but there's no live (follow) camera equivalent.
Can you use Cinemachine? The Dialogue System has good Cinemachine support. If you're using the Unity 6 preview, make sure to download the Cinemachine integration patch from the Dialogue System Extras page.
If you were in 3D, I'd recommend using the LiveCamera() sequencer command that follows the subject, versus the Camera() sequencer command that records the destination position when the command starts and moves the camera there without following the subject. The 2D equivalent of Camera() is Zoom2D(), but there's no live (follow) camera equivalent.
Can you use Cinemachine? The Dialogue System has good Cinemachine support. If you're using the Unity 6 preview, make sure to download the Cinemachine integration patch from the Dialogue System Extras page.
-
- Posts: 7
- Joined: Sun May 05, 2024 11:37 am
Re: Camera follow player walking during sequence
Hello sir, thank you for your reply!Tony Li wrote: ↑Sun May 05, 2024 12:15 pm Hi,
If you were in 3D, I'd recommend using the LiveCamera() sequencer command that follows the subject, versus the Camera() sequencer command that records the destination position when the command starts and moves the camera there without following the subject. The 2D equivalent of Camera() is Zoom2D(), but there's no live (follow) camera equivalent.
Can you use Cinemachine? The Dialogue System has good Cinemachine support. If you're using the Unity 6 preview, make sure to download the Cinemachine integration patch from the Dialogue System Extras page.
I will look into the cinemachine support now, thank you!
Re: Camera follow player walking during sequence
Glad to help!
-
- Posts: 7
- Joined: Sun May 05, 2024 11:37 am
Re: Camera follow player walking during sequence
Hello Sir,
I did some reading and found a sequence command CinemachineTarget(), which I believes works if I set a CinemachineVirtualCamera component on the game object I want the camera to follow.
Then I add the command to a dialogue entry:
However, when I run the conversation, the character walks but the camera does not follow him. I also tried CinemachinePriority() with the game object of Virtual Camera as parameter, but it also did not work.
I must be missing something,
Thank you,
Kind regards!
I did some reading and found a sequence command CinemachineTarget(), which I believes works if I set a CinemachineVirtualCamera component on the game object I want the camera to follow.
Then I add the command to a dialogue entry:
Code: Select all
CinemachineTarget(Koza, listener, follow);
AnimatorLayer(1, 1, listener, 0.5) //Increase weight of walk layer;
MoveTo(Trigger, Koza, 30); //Move character to target
I must be missing something,
Thank you,
Kind regards!
Re: Camera follow player walking during sequence
Hello,
The first parameter to CinemachineTarget() should be the name of the virtual camera GameObject, not the name of the subject that it will follow.
Instead of CinemachineTarget(), I recommend creating a vcam GameObject that is configured to follow Koza. Then set its Priority to 0, or whatever value is lower than your primary vcam's Priority, so your primary vcam will take precedence.
Then, in the dialogue entry's Sequence, use CinemachinePriority() to increase the follow vcam's Priority higher than your primary vcam. This will make it take precedence over the primary vcam.
For example, say your follow vcam is named "VcamFollowKoza". Set the Sequence to:
The first parameter to CinemachineTarget() should be the name of the virtual camera GameObject, not the name of the subject that it will follow.
Instead of CinemachineTarget(), I recommend creating a vcam GameObject that is configured to follow Koza. Then set its Priority to 0, or whatever value is lower than your primary vcam's Priority, so your primary vcam will take precedence.
Then, in the dialogue entry's Sequence, use CinemachinePriority() to increase the follow vcam's Priority higher than your primary vcam. This will make it take precedence over the primary vcam.
For example, say your follow vcam is named "VcamFollowKoza". Set the Sequence to:
Code: Select all
CinemachinePriority(VcamFollowKoza, 999);
AnimatorLayer(1, 1, listener, 0.5);
MoveTo(Trigger, Koza, 30)->Message(Done);
CinemachinePriority(VcamFollowKoza, 0)@Message(Done);
-
- Posts: 7
- Joined: Sun May 05, 2024 11:37 am
Re: Camera follow player walking during sequence
Tony Li wrote: ↑Sun May 05, 2024 9:08 pm Hello,
The first parameter to CinemachineTarget() should be the name of the virtual camera GameObject, not the name of the subject that it will follow.
Instead of CinemachineTarget(), I recommend creating a vcam GameObject that is configured to follow Koza. Then set its Priority to 0, or whatever value is lower than your primary vcam's Priority, so your primary vcam will take precedence.
Then, in the dialogue entry's Sequence, use CinemachinePriority() to increase the follow vcam's Priority higher than your primary vcam. This will make it take precedence over the primary vcam.
For example, say your follow vcam is named "VcamFollowKoza". Set the Sequence to:
Code: Select all
CinemachinePriority(VcamFollowKoza, 999); AnimatorLayer(1, 1, listener, 0.5); MoveTo(Trigger, Koza, 30)->Message(Done); CinemachinePriority(VcamFollowKoza, 0)@Message(Done);
Thank you sir, I have made those corrections,
What I did was create an empty game object, then add CineMachineVirtualCamera component to it, then dragged my player object into its transform field.
Then added suggested sequence commands to dialogue entry:
Code: Select all
CinemachinePriority(VcamFollowKoza, 999);
AnimatorLayer(1, 1, listener, 0.5);
MoveTo(Trigger, Koza, 30)->Message(Done);
CinemachinePriority(VcamFollowKoza, 0)@Message(Done);
I wanted to do it like this because the background is quite large.
Thank you!
Re: Camera follow player walking during sequence
Hi,
Assuming that vcam is taking priority (i.e., it has the highest Priority value of all vcam in the scene after using the CinemachinePriority() sequencer command), then it's a configuration issue with your vcam. Try searching up tutorial videos on YouTube, such as:
[media]]
Assuming that vcam is taking priority (i.e., it has the highest Priority value of all vcam in the scene after using the CinemachinePriority() sequencer command), then it's a configuration issue with your vcam. Try searching up tutorial videos on YouTube, such as:
[media]]
-
- Posts: 7
- Joined: Sun May 05, 2024 11:37 am
Re: Camera follow player walking during sequence
Hello Sir, this really helped me to understand Cinemachine and VCAMS more, I managed to fix the problem thanks to you!Tony Li wrote: ↑Sun May 05, 2024 10:39 pm Hi,
Assuming that vcam is taking priority (i.e., it has the highest Priority value of all vcam in the scene after using the CinemachinePriority() sequencer command), then it's a configuration issue with your vcam. Try searching up tutorial videos on YouTube, such as:
[media]]
Thank you, kind regards!
Re: Camera follow player walking during sequence
Glad to help!